Probability & Statistics · Law of large numbers

Law of large numbers

In independent repetitions of the same trial, the proportion of successes converges to its probability over the long run, while still fluctuating along the way. An early lead is diluted, not paid back.

01

The law of large numbers in this visualization

Let X1,X2,…X_1, X_2, \dots be independent draws from one distribution with a finite mean μ=E[X]\mu = E[X] (it is enough that E∣X∣<∞E|X| < \infty), and let Xˉn\bar X_n be the average of the first n. The law of large numbers says that Xˉn→μ\bar X_n \to \mu: in probability (the weak law) and with probability one (the strong law). For a coin, XiX_i is 1 for heads, so Xˉn=p^n=Hn/n\bar X_n = \hat p_n = H_n/n is the proportion of heads and μ=p\mu = p. The page follows one or more paths of 100 000 tosses and asks what makes the proportion settle.

One deviation, two scales
Hn−np=n (p^n−p),SD(p^n)=p(1−p)n,SD(Hn−np)=np(1−p)H_n - np = n\,(\hat p_n - p), \qquad \mathrm{SD}(\hat p_n) = \sqrt{\tfrac{p(1-p)}{n}}, \qquad \mathrm{SD}(H_n - np) = \sqrt{np(1-p)}

The upper layer shows p^n\hat p_n, the lower one the surplus of heads over the expected count, Hn−npH_n - np; 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 [an,bn][a_n, b_n] with at most 2.5% of HnH_n below it and at most 2.5% above, so it holds at least 95% (the readout gives the exact coverage). In proportion it is [an/n, bn/n][a_n/n,\ b_n/n], in count [an−np, bn−np][a_n - np,\ b_n - np]: 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 5/n5/n. The lead is diluted, not repaid.

02

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 1/n1/\sqrt{n}: 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).
03

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.
04

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.