Concept map / Coin toss
Share
The law of large numbers
Flip a coin many times and watch the share of heads settle near its true chance.
1Flip a coin and watch the share of heads
Flip a fair coin ten times and seven heads is nothing unusual. That is 70%, a long way from half. Flip it a thousand times and you will almost never be that far off. The pull toward half as the flips pile up is called the law of large numbers.
Each small circle below is one flip, orange for heads and blue for tails. The orange line is the share of heads so far, and the shaded band is where a run usually stays. Flip a few times, then start another run and compare the two.
Press Flip 10 to start.
More controls
2Five heads in a row, then what?
A fair coin has just landed heads five times in a row.
What about the sixth flip?
3The count drifts while the share settles
This chart shows the same run as a count: heads minus the number you would expect, n × p. The count gap does not shrink. Its typical size grows with √n, to about 16 heads after 1,000 fair flips. The share of heads still settles, because that gap is divided by n, and n grows much faster than √n.
Flip the coin in section 1 to see the count gap.
Four times as many flips halves it. Point at the formula to light up the band in section 1.
A common misreading is that the law of large numbers evens out the count. It does not. After 10,000 fair flips, being 50 heads ahead or behind is ordinary, and that is half a percentage point of the share.
4Check yourself
The tasks use the buttons in section 1 and tick themselves when you meet them.
- Flip at least 1,000 times in one run and end within 2 percentage points of the coin's chance of heads.Now: No flips yet
- Make five runs of at least 100 flips each, pressing Start another run between them. See how far apart they start and how close they end.Now: 0 runs of 100 or more
- Keep flipping one run until the typical gap in section 3 is down to 1 percentage point, and note how many flips that took.Now: No flips yet
5Flip 10,000 times in R
The snippet flips a fair coin 10,000 times and prints the share of heads, the count gap and the typical gap after 10, 100, 1,000 and 10,000 flips. The flips are random, so the first columns will not match your runs. The typical gap does not depend on luck: 0.016 after 1,000 flips and 0.01 after 2,500.
Track the share of heads over 10,000 flipsShow the code
# A fair coin, as on the page: p = 0.5
set.seed(1)
p <- 0.5
tosses <- rbinom(10000, size = 1, prob = p)
# Proportion of heads after 10, 100, 1,000 and 10,000 tosses
n <- c(10, 100, 1000, 10000)
heads <- cumsum(tosses)[n]
prop <- heads / n
# Heads above or below the expected number, n * p
gap <- heads - n * p
# Typical gap between the proportion and p
sd_prop <- sqrt(p * (1 - p) / n)
round(cbind(n, prop, gap, sd_prop), 3)
# The typical gap falls to 1 percentage point at 2,500 tosses
sqrt(p * (1 - p) / 2500)Uses base R only.
What the coin shows
- Flip a fair coin again and again and the share of heads settles near 50%.
- The coin has no memory. After five heads in a row, the next flip is still 50:50.
- The count of heads can drift further from n × p as you flip, even while the share closes in on p.
- The typical gap between the share and p is √(p(1 − p) / n), so four times as many flips halves it: 1.6 percentage points after 1,000 fair flips and 0.8 after 4,000.
- Counting the heads in a fixed number of flips gives the binomial distribution, the next lesson.
Recommended reading
- Introductory Statistics 2eBarbara Illowsky and Susan Dean§4.2, the law of large numbers