All Questions

Tagged with
Filter by
Sorted by
Tagged with
10 votes
3 answers
3k views

Dice odds: Simulating a game of Craps

My brother turns 21 in a couple of weeks and my parents and I are taking him to Las Vegas. For my 21st, I brought $200 to gamble in Vegas and came home with around $450, mostly from playing craps. I ...
Kevin's user avatar
  • 3,841
7 votes
2 answers
6k views

Generate a matrix of all possible outcomes for throwing n dice (ignoring order)

In cases where order does matter, it's rather easy to generate the matrix of all possible outcomes. One way for doing this is using expand.grid as shown here. What if it doesn't? If I'm right, the ...
Brani's user avatar
  • 6,614
6 votes
9 answers
13k views

Determine Frequency of numbers showing up in dice rolls

For a game I'm trying to determine the frequency that a certain # will show up at a given # of dice being rolled. I know... that question seems odd. Let me try to explain it with real numbers. So, ...
bugfixr's user avatar
  • 8,057
6 votes
1 answer
264 views

Expand random range of integers using probability distribution

I tried to solve the classic problem of generating a random integer between 1 and 7, given a function that generates a random integer between 1 and 5. My approach was to add the result of 2 calls to ...
The Bic Pen's user avatar
  • 1,039
5 votes
2 answers
1k views

Calculate probability of a fair dice roll (in non-exponential time)

Variations on this are pretty common questions, but all my google-fu has left me stumped. I would like to calculate the odds of a fair dice roll, but I want to do it efficiently. There are lots of ...
Aaron Small's user avatar
4 votes
4 answers
3k views

Calculating odds distribution with 6-sided dice

I'm trying to calculate the odds distribution of a changing number of 6-sided die rolls. For example, 3d6 ranges from 3 to 18 as follows: 3:1, 4:3, 5:6, 6:10, 7:15, 8:21, 9:25, 10:27, 11:27, 12:25, ...
Stephen's user avatar
  • 41
3 votes
1 answer
723 views

Calculate the probability in R for sum of two dice rolls

I have a matrix consist of the sum of dice 1 and dice 2 OR Y = D1 + D2 outer(1:6, 1:6, "+") The output is: [,1] [,2] [,3] [,4] [,5] [,6] [1,] 2 3 4 5 6 7 [2,] 3 ...
Jake Parker's user avatar
3 votes
3 answers
2k views

probability of T total eyes when throwing N dice with S sides

I want to calculate the probability of the event that the sum of all eyes of n dice with s sides (numbered from 1 to s) is equal to t. My language is Python 3. My current approach is pretty much a ...
Byte Commander's user avatar
3 votes
3 answers
4k views

Dice Sum Probability with Different types of Dice

I am currently working on a java application where I need to calculate the probabilities of rolling each sum for a variety of dice. The dice types I am supporting are d4 (4 sided dice), d6 (6 sided ...
Andrew's user avatar
  • 922
3 votes
4 answers
1k views

How to calculate the probability of getting the sum X using N six-sided dice

The Challenge: For example, what is the probability of getting the sum of 15 when using 3 six-sided dice. This can be for example by getting 5-5-5 or 6-6-3 or 3-6-6 or many more options. A brute force ...
riorio's user avatar
  • 6,706
3 votes
4 answers
2k views

Python program that simulates rolling a 6 sided die and adds up the result of each roll till you roll a 1

so this is the code I wrote that attempts to answer the question in the title : import random print("Well, hello there.") while True: a = random.randint(1,6) sum = 0 if(a==1): #If a one ...
ggezpython3's user avatar
2 votes
1 answer
71 views

Rolling N Non-regular Dice in Constant Time

Say I have a non-regular dice defined by probabilities in a list that add up to one, e.g [0.1, 0.3, 0.4, 0.2]. I can use the following code to simulate rolling that dice n times: import random from ...
Max's user avatar
  • 494
2 votes
2 answers
507 views

How to make dice (uniform) distribution using coin toss?

I can use only randint(0,1), it's tossing coin (50% head, tail). Using above, how can I make dice distribution (1 to 6 uniform distribution)? I just think that if I toss many times enough, and sum all ...
user225549's user avatar
2 votes
3 answers
98 views

Probabilities and rpg dice goes wrong for high values

I made this short code to calculate the chances of a success rolling dice, and it worked very well... but not in big numbers. Se the code, I'll explain better below. def calc_dados(f_sucessos = 1, ...
Daniel Capua's user avatar
2 votes
2 answers
416 views

How can I use a recursive loop to find the amount of times a value shows up between rolling any amount of dice with any amount of sides?

I am trying to write a function that prints out a dictionary that shows the specific amount of values a combination of same-sided dice can possibly roll. Example output for three 6-sided dice input: 6,...
Joshua Penrod's user avatar
1 vote
2 answers
859 views

Attempting to estimate the expected number of dice rolls needed to obtain all possible sums of two dice when I roll 2 6 sided fair dice

So I am doing a sample exam question in preparation for my stats exam and I have hit a dead end. The question is asking: If you roll two 6-sided fair dice until you get all possible outcomes (i.e. ...
Renee Ofadu's user avatar
1 vote
2 answers
1k views

Formula to calculate chance (probability) of a dice side based on its value

So I am making a simple Dice that has 6 sides, but I want to modify the chances of those 6 sides. Now my dice can have N sides, it grows, so you start with 6 sided dice and you may get up to 10 sided ...
GGio's user avatar
  • 7,615
1 vote
4 answers
13k views

A Program for Simulating the Rolling of 2 Dice

The following is the whole question. Write a program that simulates the rolling of two dice. The program should use rand to roll the first die and should use rand again to roll the second die. ...
Casper's user avatar
  • 4,565
1 vote
2 answers
117 views

Reorganise 2x36 dataframe to a 6x6 dataframe. Dice throw visualisation

I've created a data-frame of all the possible outcomes from a dice throw as 2x36 dataframe. d1 d2 1 1 1 2 2 1 3 3 1 4 4 1 5 5 1 6 6 1 7 1 2 8 2 2 9 3 2 10 4 ...
user3200293's user avatar
1 vote
1 answer
136 views

Trying to find a percentage outcome of 3 dice rolls

Hey guys below I will paste my code for finding out the percentage chance of rolling the outcome (Please see my last outcome for a reminder) Pretty much what I am trying to do is roll 3 dice store ...
user3576108's user avatar
1 vote
2 answers
114 views

Calculating the different outcomes for 2 to 6 different dices

updated code I know my programming is garbage but I'm very new to this. Sorry if it's an eyesore to look at. I have to calculate the relative frequency for the sums of 2 dice up to 6 dices. So far I ...
Khan's user avatar
  • 33
1 vote
2 answers
451 views

Count the Number of 6s Rolled on a Number of Dice in R

I am trying to develop code that will tell me the likelihood of rolling at least one six given 1 thru 20 die using. I am specifically trying to build a single piece of code that loops through the ...
Englishman Bob's user avatar
1 vote
1 answer
290 views

Printing the probability when a die rolls all 6 sides

I am trying to print the expected amount of when a fair die is rolled and to keep rolling until all 6 sides are rolled. What I am trying to do is when as an example a 1 is rolled it is added to a ...
l.m's user avatar
  • 131
1 vote
1 answer
1k views

How to calculate the probability of the sum of n rolled m sided dice of being a certain value or greater

I'm trying to write some Python code which will calculate the probability of the sum of n rolled m sided fair dice of being a certain value or greater. The inputs are the sum of all dice rolls, the ...
Ginger Leprechaun's user avatar
1 vote
2 answers
108 views

How do i keep my loop from repeating my random values?

So i was learning how to handle probabilities and how to plot them in Python. I came across a problem where i needed to find the probability of the sum of 2 dices being > 7 or odd. I know the ...
Binbougami's user avatar
1 vote
1 answer
9k views

Python program that runs a game of pig with a human player and the computer

So in a nutshell, who goes first is decided randomly. When the human players turn does come up, he/she has the option to either hold or roll. If he chooses to roll, a dice is rolled and the values are ...
ggezpython3's user avatar
1 vote
1 answer
1k views

Monte Carlo Dice Simulation in R

Hi I am trying to solve a problem where a player has $10. A coin is flipped, if the player calls it correctly he earns $1, if he is incorrect he loses $1. What are the odds that he will reach $0 ...
Mary Popko's user avatar
1 vote
3 answers
724 views

Estimating Probabilities in Perudo

I am new to coding and using R. I am working on a project to simulate the game Liar's Dice, also known as Perudo, and have some questions about creating the simulation. Basically, the game consists of ...
Chris C's user avatar
  • 23
1 vote
0 answers
319 views

How to create a javascript function that calculates probability percentages in values from 0-99

in the following code, pretend the two broken images are each dice that show anything from 0-9. that means that when you add their values they could show anything from 0-99 making them 100 sided. In ...
ImNewToStackOverflow's user avatar
1 vote
2 answers
3k views

How to simulate rolling dice multiple times using PHP

I want to simulate rolling two six-sided dice X number of times using PHP to see how often each possible combination actually occurs (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, or 12). What would be a good ...
jerdiggity's user avatar
  • 3,665
1 vote
2 answers
3k views

Dice Roll Simulator C++

In class we received an assignment to make a C++ program that simulates rolling a die (or multiple). Simple enough, I did that really easy, even got it to roll more than 1 die at once and to count how ...
Jarrod A.'s user avatar
0 votes
2 answers
3k views

Python - calculate die rolls and count doubles

The problem: I need to roll 3 dice. If two (or three) of the dice return the same number, stop. If the 3 dice are all unique (e.g. 2, 4, and 6) then roll again. Perform this either until doubles/...
Mike Earley's user avatar
  • 1,273
0 votes
3 answers
829 views

Greater chance to roll 6 with dice in Java

I was wondering how can I program a dice which has a greater chance to roll a 6? I've tried everything but I just cant figure the algorithm. The probability of six is given by the user. I just don't ...
HyperParameter's user avatar
0 votes
4 answers
7k views

Probability Dice Game in Python with two dices

I want to interate 1000 times over the following function to find out if you win or loose money in this game. The game is designed as such that you throw a pair of dice and get money back or loose ...
Stephan Kristyn's user avatar
0 votes
1 answer
2k views

Dice Statistics Program

I'm trying to write a java program that asks the user to enter in the amount of dice to roll and the amount of times to roll the dice. The program that I wrote so far isn't rolling the dice properly: ...
Little_Berry's user avatar
0 votes
2 answers
6k views

Relative Frequency Histograms and Probability Density Functions

The function called DicePlot simulates rolling 10 dice 5000 times. The function calculates the sum of values of the 10 dice of each roll, which will be a 1 ⇥ 5000 vector, and plot relative frequency ...
Priya Sharma's user avatar
0 votes
2 answers
1k views

How to use np.random.randint() to roll n dice, noting that each has a potentially different number of faces denoted by a vector f

I am trying to simulate the single roll of n dice, where each of the die can potentially have f faces. For example, if 𝑓=[2,5,7], then three dice with 2, 5 and 7 faces are rolled. Thank you!
gte's user avatar
  • 151
0 votes
3 answers
73 views

Why does the score not equal 0 when I roll a 1?

So I'm making a dice game where if either ofd the dice roll a 1, the score is 1, but I can't seem to make that work. I believe everything else it ok. var die1 = Math.floor(Math.random()*6 + 1); ...
JackWalsh's user avatar
0 votes
2 answers
4k views

Throwing n dice m times, what is the probability of getting atleast one six

I have the following code trying to solve the problem below: Thrown n dice m times, calculate the probability of getting at least one 6. I know that the exact probability of getting at least 1 six ...
Palaios's user avatar
  • 57
0 votes
1 answer
937 views

Dice Probability in R script [closed]

Roll five six-sided dice. Write a script in R to calculate the probability of getting between 15 and 20 as the total sum of your roll. Exact solutions are preferred. dice <- expand.grid(1:6, 1:6, 1:...
b14108's user avatar
  • 33
0 votes
3 answers
292 views

Calculating the random sum and its probabilities for 1-6 dice

My error message is File "/Users/CoconutTime/Downloads/sista_bomben.py", line 60, in probability_sums2 percentage_2 = (count[j] / freq)*100 IndexError: list index out of range and I don't really ...
Khan's user avatar
  • 33
0 votes
2 answers
264 views

Show all the combinations of exploding dice

I am trying to evaluate the effectiveness of different units in a tabletop game (Mantic's Deadzone, for anyone who is interested) that uses exploding eight-sided dice (D8). For example, a player rolls ...
JimmyTheOne's user avatar
0 votes
2 answers
3k views

A C++ question about dice probability calculation

Write a program to find out the probability of each "total value" when several unbiased irregular dices (possibly with different number of faces) are thrown at the same time. When an unbiased dice is ...
CodingKingggg's user avatar
0 votes
1 answer
2k views

Calculating the probability of throwing five different numbers when you throw five six-sided dice

So I just started learning python 4 days ago from C++ and I got bit stuck on one coding challenge and is calculating the probability of throwing five different numbers when you throw five six-sided ...
Midou35000's user avatar
0 votes
2 answers
3k views

Simulates repeated rolls of a pair of dice until 100 rolls of r have been obtained; the number of rolls is then printed

I'm trying to count how many rolls it takes to get 100 rolls of a sum of two dice, r (2-12) and prints it. This is what I've tried so far: from random import randrange def diceprob(r): count = 0 ...
Frank's user avatar
  • 349
0 votes
1 answer
167 views

Dice Statistics

I wanted to build a dice Stats Simulator in Python. The idea is that you have a starting array, containing [1,...,1] for the lowest possible dice rolls, a one. I already have one example for 4d4 and ...
Roy Mustang's user avatar
0 votes
1 answer
319 views

Build a function to roll a list of dice provided by `f`, and calculate the probability that the largest number among the outcomes is `x_max`

I have got up to this: def largest_face(f, x_max): # inputs: f is a list of integers and x_max is an integer # output: a variable of type 'float' #generate len(f) random throws of (len(f)...
gte's user avatar
  • 151
0 votes
1 answer
602 views

Python: Roll a dice for 12 times, calculate the probability if each number equally shows up twice

I've drafted the below code for the captioned question, but the return result is always 0. Could anyone please help me figure out what's the problem here? Thanks a lot! import random dice_sides = 6 ...
Valerie Wu's user avatar
0 votes
2 answers
4k views

Python program that simulates a game of dice with both players controlled by the computer

The program should randomly choose which player goes first. It should keep a total score for each player, and alternate turns between the computer players until one player ends its turn with a score ...
ggezpython3's user avatar
0 votes
1 answer
1k views

Python program that simulates a full one player game of pig, starting at a totalscore of 0 and playing turn after turn until it reaches 100 points

So here is a sample output: - rolled a 2 - rolled a 1 Pigged out! Turn score = 0 New total score = 0 - rolled a 1 Pigged out! Turn score = 0 New total ...
ggezpython3's user avatar