Section 15.46

Law of large numbers

Definition

The law of large numbers (LLN) is a theorem of probability theory: the average of many independent observations that follow one distribution gets closer to the distribution’s expected value, its probability-weighted average, as the number of observations grows. The weak law says that the probability of the average missing the expected value by more than any fixed amount goes to 0. The strong law says that, with probability 1, the sequence of averages converges to the expected value. The target is the expected value of what is measured, bias included.

The idea

A logic analyzer, an instrument that records digital signals over time, measures the duration of a function call, but its trigger delay adds 2 ms to every reading, and each reading also has a random error of a few milliseconds up or down. Averaging 100 readings gives a value close to the true duration plus 2 ms. Averaging 10,000 readings gives a value even closer to the true duration plus 2 ms. More readings shrink the random error and leave the 2 ms untouched.

Random errors point in both directions, so in a long sum most of them cancel, and dividing by the count shrinks what is left. A systematic error has the same sign and size in every reading, so the sum of the systematic errors grows exactly as fast as the count, and dividing by the count leaves the error whole. A bathroom scale that reads 2 kg heavy is a fair picture: weighing oneself 100 times and averaging gives a very steady number that is 2 kg too high. The picture shows only a constant offset. Real instruments can also have errors that grow with the measured value, such as a clock that runs 0.1% fast, and averaging does not remove those either.

How it works

  1. Model. Let X1,X2,…X_1, X_2, \dots be the observations, independent and identically distributed §11.5 (IID): each comes from the same distribution, with expected value μ\mu, and no observation affects another. Let X‾n=(X1+…+Xn)/n\bar X_n = (X_1 + \dots + X_n)/n be the mean of the first nn.

  2. The mean is centered on μ\mu. The expected value of a sum is the sum of the expected values, so E[X‾n]=nμ/n=μE[\bar X_n] = n\mu/n = \mu for every nn, where EE denotes the expected value.

  3. Its spread shrinks. Suppose each observation has a finite variance §11.14 σ2\sigma^2, the average squared distance from μ\mu. For independent observations variances add, so the sum has variance nσ2n\sigma^2 and the mean has variance nσ2/n2=σ2/nn\sigma^2/n^2 = \sigma^2/n.

  4. Turn spread into a probability. Chebyshev’s inequality says that a random quantity with finite variance lies at least ϵ\epsilon away from its mean with probability at most its variance divided by ϵ2\epsilon^2, for any ϵ>0\epsilon > 0. Applied to X‾n\bar X_n, it gives Pr(|X‾n−μ|≥ϵ)≤σ2/(nϵ2)\Pr(|\bar X_n - \mu| \ge \epsilon) \le \sigma^2/(n\epsilon^2).

  5. Let nn grow. For a fixed ϵ\epsilon, the right-hand side goes to 0. This proves the weak law when the variance is finite.

Stronger theorems need less. For IID observations, a finite expected value of |X1||X_1| is enough for both the weak law (Khinchin’s theorem) and the strong law (Kolmogorov’s theorem); the variance may be infinite.

Bias enters through μ\mu. Write each reading as X=θ+b+eX = \theta + b + e, where θ\theta is the true value one wants, bb is a constant bias, and ee is a random error with mean 0. Then μ=θ+b\mu = \theta + b, and the average converges to θ+b\theta + b.

Worked example

A function’s true duration is θ=20\theta = 20 ms. Each reading adds a constant bias of b=2b = 2 ms and a random error with mean 0 and variance 4ms24\ \mathrm{ms}^2, that is, standard deviation 2 ms. Assume that the random errors of different readings are independent. Each reading therefore has expected value μ=22\mu = 22 ms and variance σ2=4ms2\sigma^2 = 4\ \mathrm{ms}^2. Take the tolerance ϵ=0.5\epsilon = 0.5 ms.

These are guaranteed upper limits, usually far above the true probabilities.

The average closes in on 22 ms, not on the true 20 ms. Its mean squared error, the expected squared distance from the true 20 ms, is the square of the bias plus the variance of the mean: 22+0.04=4.04ms22^2 + 0.04 = 4.04\ \mathrm{ms}^2 at n=100n = 100, and 22+0.0004=4.0004ms22^2 + 0.0004 = 4.0004\ \mathrm{ms}^2 at n=10,000n = 10{,}000. A hundred times more data removed almost all of the random part and none of the 4ms24\ \mathrm{ms}^2 that comes from the bias. The square root of the mean squared error never falls below 2 ms, however many readings are taken.

Stated precisely

Let X1,X2,…X_1, X_2, \dots be independent random variables, numerical outcomes of a random experiment, with one common distribution and a finite expected value μ=E[X1]\mu = E[X_1]. Let X‾n\bar X_n be the mean of the first nn.

If the quantity one wants is θ\theta and E[X1]=θ+bE[X_1] = \theta + b with a constant bb, both laws give convergence to θ+b\theta + b. With finite variance, the mean squared error is E[(X‾n−θ)2]=b2+σ2/nE[(\bar X_n - \theta)^2] = b^2 + \sigma^2/n, which falls toward b2b^2, not toward 0. A bound computed with Chebyshev’s inequality can exceed 1, for example at small nn; it is then true but says nothing, as with the union bound §15.42.

Limits and common mistakes

More data does not remove bias. Only knowledge from outside the data does: calibration §11.42, which compares the instrument with a reference of known value and corrects the readings, or a second, independent measurement method.

An error shared by all readings of one session acts as bias within that session. If one setup shifts every reading of a run by the same unknown amount, averaging within the run cannot remove the shift. Repeating whole runs with independently sampled setups lets their shifts average out if those shifts have mean zero. A shift shared by every setup persists.

The law does not say that deviations get corrected. After 100 tosses of a fair coin with 60 heads, the next tosses are still fair. The share of heads approaches 0.5 because later tosses dilute the early excess, not because tails become more likely. The difference between the number of heads and half the number of tosses typically grows, roughly like the square root of the number of tosses.

The law says that the average gets close, not how fast. Under the finite-variance, independent sampling model above, Chebyshev’s inequality bounds the probability of a deviation at each sample size. The central limit theorem §15.45 supplies a normal approximation near the mean. Its accuracy at a particular sample size needs a separate argument.

Without a finite mean there is nothing to converge to. The average of observations from the Cauchy distribution, whose tails are so heavy that it has no mean, does not settle at all.

If the observations drift, or depend strongly on each other, the average may converge slowly, converge to something else, or not converge. If only some readings are kept, such as those from completed trials, the average converges to the mean of the kept readings, a conditional mean, as the conditional probability §15.43 entry explains.

An instrument stuck at 22 ms gives a perfectly stable average. To test accuracy, measure an event with a known duration or compare against an independent reference.

Questions answered

Does more data remove systematic instrument bias?

No, more data does not remove systematic instrument bias. By the law of large numbers, the average of more readings converges to the expected value of the readings, and that expected value includes the bias. If an instrument adds a constant 2 ms to every reading of an event that truly lasts 20 ms, the average approaches 22 ms. With independent, zero-mean random errors of variance σ2\sigma^2, the mean squared error of the average of nn readings is 22+σ2/n2^2 + \sigma^2/n: more readings shrink only the second term, so the root mean squared error never falls below the 2 ms bias.

Bias is removed only by knowledge from outside the readings: calibration against a reference of known value, a corrected model of the instrument, or an independent measurement method. Independent errors give the variance reduction in this example. Dependent errors can also average out: take pairs of errors +e+e and −e-e in random order, and the error of each pair average is exactly zero. An error that stays the same across all readings survives averaging.

Related entries: Sample mean (§11.12), Standard error (§11.15), Calibration (§11.42), Central limit theorem (§15.45), Resolution versus precision versus accuracy (§11.34), Conditional probability (§15.43).