Law of Large Numbers – Coding a Dice Roller Simulator

Law of Large Numbers - Coding a Dice Roller Simulator

This simulation demonstrates the law of large numbers, a key theorem in probability theory, which describes the result of performing the same experiment a large number of times.



According to the law, the average of the results obtained from a large number of trials should be close to the expected (theoretical) value, and will tend to become closer as more trials are performed.

When rolling a die, the theoretical chance of landing on each face is 1/6. But when conducting an experiment with only a few rolls, the results are likely to be much different. However, rolling one die a thousand times will produce results closer to 16.67% (1/6).


Try rolling the die 1, 5, 100 and 1000 times.

Observe the results.


Try it for yourself!

For more lessons, activities and ideas, grab a copy of my book, Code Breaker, on Amazon here!

Extensions and Modifications:

Can you program this die to be weighted? Can you remix my code to produce a die that lands on 6 more often than the other 5 faces? Give it a try!



(Visited 1,460 times, 1 visits today)

Leave a Reply

Email *