TwiddleLab / Math / Probability by Simulation
Flip a Thousand Coins
What you will learn
- The relative frequency is how often something happened: heads / flips.
- Law of large numbers: the more flips, the closer the frequency gets to the real chance.
- A few flips prove little: 7 heads in 10 is normal. 700 in 1000 is not.
How the lesson goes
You flip a coin 10 times and get 7 heads.
Flip it yourself. Then stamp it: is this coin fair or rigged?
A fair coin. Flip it a thousand times.
The line is the share of heads so far. Start with single flips, then go big.
A coin from a magic shop. Where will its line settle?
Here are its first 20 flips. Drag the pin to where the line will be after 1000 flips, then flip.
With few flips the share wobbles a lot. With 1000 flips it stays close to the coin's real chance, here 0.3.
What the line was showing
Relative frequency = how many times it happened / how many tries. 7 heads in 10 flips is 0.7.
Law of large numbers: as the tries pile up, the relative frequency settles near the true probability.
Few tries wobble a lot, many tries wobble a little. That's why you can estimate a chance by simulating.
Which test would catch a rigged coin?
Run both walls of fair coins. Then tap the wall where 70% heads would look strange.
A fair coin gets 7 or more heads in 10 flips about 17% of the time, so 70% proves nothing. In 1000 flips the share almost never leaves 0.47 to 0.53.
Game: catch the loaded coin.
One coin lands heads 65% of the time. You have 600 flips. Test, then tap the coin you accuse.
Code flips coins too. What will it print?
random_number(1, 2) gives 1 or 2, like heads or tails. Drag the pin to your guess, then Run.
Each pass of the loop is one flip with chance 1/2 of a 1. Over 1000 passes the count lands near 500, give or take about 30.
Suspicious or normal for a fair coin?
Tap every result that looks too far from 0.5 for its number of flips.
How far a fair coin wanders shrinks as the flips grow: about 0.3 either way for 10 flips, 0.1 for 100, 0.03 for 1000.
Back to the coin with 7 heads.
Your 10 flips are already on the chart. Flip it up to 1000.
Previous lesson: Chance Is a Fraction · Next lesson: Counting the Outcomes · Part of the course: Probability by Simulation
Lessons are interactive and need JavaScript. Turn it on to play them.