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

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 = 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?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question
Question Posted: