# Dice Score Frequency Analysis In this challenge we will use a Python algorithm to perform a frequency analysis of the score obtained when throwing a set of two dice.

#### Frequency analysis using 1 dice

Let’s consider a single 6-sided dice.

When using single dice, the score of the dice can be any of the 6 values/sides (1 to 6). Each value has an equal probability of 1/6.

The dice experiment can be simulated using a computer algorithm to simulate throwing a dice a 1,000 times and keeping a record of the number of times each of the 6 values appeared. We can then calculate the frequency of each value as a percentage. In theory, each value should have a very similar frequency of around 16.67% (matching the 1/6 probability).

When completing such an experiment in real life, we would mot likely use a tally chart to record the number of occurrences for each of the 6 possible values. To record our “tallies” in a Python program we will use a dictionary with 6 keys (the 6 values of a dice, from 1 to 6) and for each key, the associated value will be the number of occurrences of when the value appeared.

Here is the Python implementation of our dice experiment (frequency analysis).

Run the above code several times.

• Do you notice the frequencies changing slightly every time you run this code?
• Does the experiment confirm the theory: each side having an equal probability, the percentage for each value should be 16.67%?
• What do you think will happen if, instead of 1,000 iterations you were completing 1,000,000 iterations?
• Change the value of n in the above code from 1,000 to 1,000,000 and run the code. Does the outcome confirm your prediction?

#### Using two dice

We are now going to simulate the same experiment, this time using two dice, and recording the total score (by adding the value of both dice). The dice score will be as follows:

 Total Score Possible Combinations Probability 2 1+1 1/36 = 2.78% 3 1+2 or 2+1 2/36 = 5.56% 4 1+3 or 2+2 or 3+1 3/36 = 8.33% 5 1+4 or 2+3 or 3+2 or 4+1 4/36 = 11.11% 6 1+5 or 2+4 or 3+3 or 4+2 or 5+1 5/36 = 13.89% 7 1+6 or 2+5 or 3+4 or 4+3 or 5+2 or 6+1 6/36 = 16.67% 8 2+6 or 3+5 or 4+4 or 5+3 or 6+2 5/36 = 13.89% 9 3+6 or 4+5 or 5+4 or 6+3 4/36 = 11.11% 10 4+6 or 5+5 or 6+4 3/36 = 8.33% 11 5+6 or 6+5 2/36 = 5.56% 12 6+6 1/36 = 2.78% 