Explore the Law of Large Numbers

Law of Large Numbers Simulator

Try a comparison:

1Parent population

Drag on the chart to draw your own population.

2Draws so far· path 1

Every value drawn so far in path 1. As n grows the bars take the shape of the population.

3Running mean

4Chance of missing

How to use this simulator

What you see. Each path is one long sequence of draws from the population in panel 1 — think of one person rolling a die again and again. Panel 2 shows every value drawn so far in path 1. Panel 3 plots each path's running mean x̄ₙ (the mean of its first n draws) against n. Panel 4 checks the convergence.

The law of large numbers. As n grows, x̄ₙ gets close to μ and stays there. Precisely (the weak law): for any margin ε, the chance that x̄ₙ misses μ by more than ε goes to 0. Panel 4 estimates that chance from all the paths and compares it with Chebyshev's bound σ²/(nε²) and the normal approximation 2(1 − Φ(ε√n/σ)).

Things to try.

  • Coin: proportion vs count — the share of heads settles at 0.5, yet heads − n/2 keeps wandering further from 0. Nothing "evens out"; the gambler's fallacy is wrong.
  • Many paths — a single path looks erratic, but fifty of them are squeezed into the funnel μ ± 2σ/√n.
  • Bimodal — μ = 16 sits between the two peaks, a value you will almost never draw, yet the running mean still settles on it. The mean need not be a typical value.
  • Any shape works — Trimodal, Skewed or one you draw yourself: panel 2 slowly takes on the population's shape, and x̄ₙ still goes to μ. Only the speed changes, through σ: compare how wide the funnel is for Normal (σ = 5) and Trimodal (σ ≈ 7).
  • Heavy tail: no mean — the Cauchy distribution has no mean, so the law does not apply: occasional huge values keep throwing the running mean off, and the chance of missing never shrinks.
  • Slow play draws one value at a time so you can follow the first few dozen draws; switch to Play to race on to 10,000.
  • Turn on Log n to see the early wild swings and the late calm on one chart, and Zoom to look closely around μ.

Colours. Red ochre is the population, tin grey the draws, dark blue the running means and dark green the convergence check. The bold line is path 1; dashed lines are theory.