Question: Dice simulation. The following code computes the exact probability distribution for the sum of two dice: int[] frequencies = new int[13]; for (int i =

Dice simulation. The following code computes the exact probability distribution for the sum of two dice:

int[] frequencies = new int[13];

for (int i = 1; i <= 6; i++)

for (int j = 1; j <= 6; j++)

frequencies[i+j]++;

double[] probabilities = new double[13];

for (int k = 1; k <= 12; k++)

probabilities[k] = frequencies[k] / 36.0;

The value probabilities[k] is the probability that the dice sum to k. Run experiments that validate this calculation by simulating n dice throws, keeping track of the frequencies of occurrence of each value when you compute the sum of two uniformly random integers between 1 and 6. How large does n have to be before your empirical results match the exact results to three decimal places?

Step by Step Solution

3.32 Rating (146 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To validate the calculation of the probability distribution for the sum of two dic... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction To Programming Questions!