The law of large numbers in this visualization
Let be independent draws from one distribution with a finite mean (it is enough that ), and let be the average of the first n. The law of large numbers says that : in probability (the weak law) and with probability one (the strong law). For a coin, is 1 for heads, so is the proportion of heads and . The page follows one or more paths of 100 000 tosses and asks what makes the proportion settle.
The upper layer shows , the lower one the surplus of heads over the expected count, ; for a fair coin it is half of “heads minus tails”. The same deviation shrinks above and grows below. The dashed band at each n is the exact 95% range of the binomial distribution: the narrowest whole interval with at most 2.5% of below it and at most 2.5% above, so it holds at least 95% (the readout gives the exact coverage). In proportion it is , in count : the same event. With a head start of ten heads, a coupled coin that began with five shares every later toss: the two always differ by exactly 5 heads, so their proportions differ by exactly . The lead is diluted, not repaid.
Things to notice
- The band is pointwise: at each fixed n at least 95% of paths are inside it, but a path that stays inside at every n is much rarer. A path leaving the band now and then is what the law predicts, not a failure of it.
- Nothing pays back an early lead. After a streak of heads the next toss is still heads with probability p (the gambler’s fallacy says otherwise; the “After-streak counts” window counts it). The proportion settles because the same surplus is divided by an ever larger n.
- The band narrows like : at the same 95%, one more correct decimal place needs about a hundred times as many tosses. The law needs a finite mean: for the Cauchy distribution the average of n draws is no more settled than one draw (see the central limit theorem page).
- Jacob Bernoulli proved the case of coin-like trials in Ars Conjectandi (1713); the name “law of large numbers” is Poisson’s (1837).
Controls
- The red key replays tosses computed in advance with a fixed seed; pressed while running it stops, pressed again it goes on, and at the end it tosses the next seed. Press or drag anywhere on the picture to move the cursor; the readouts use only the tosses left of it. Share stores the seed, the algorithm’s version and the cursor.
Related
- H16Binomial distributionPlanned
- H19Central limit theorem
- H18Sampling distributionPlanned
- H20Confidence intervalPlanned
- H05Normal distributionPlanned
Further reading: Wikipedia: Law of large numbers; OpenStax, Introductory Statistics 2e, 3.1 Terminology; MacTutor History of Mathematics: Jacob Bernoulli.