The law of large numbers

The question
How often will a sample average miss its target by more than 0.1 as you collect more observations?
Choose a trend, then follow repeated runs of the same experiment.
- 1 SeePredict how often averages miss.
- 2 TryTest another population and plan a sample.
- 3 ProveBuild a probability bound.
- 4 ApplyUse the law in five problems.
Before you start · 3 quick checks on means, variance, and events
Two ideas before you start
2 ideasA running mean uses the observations so far
Observation bars and a dashed line at their arithmetic mean.
Switch the sample. The dashed line is its mean; it is a statistic computed from the whole list.
Exact definition
For observations \(X_1,X_2,\ldots\), the running sample mean after \(n\) observations is
\[\bar X_n=\frac{X_1+\cdots+X_n}{n}.\]Before sampling, this is a random variable. One realized sequence gives one running-mean path. The sampling-distributions lesson studies its distribution at a fixed sample size. Here we follow that distribution as the size changes.
A miss means leaving a fixed band
A fixed target band and a movable value on a number line.
Select a value to see whether it is outside the band. A value exactly on its edge is inside for this lesson's strict miss event.
Exact definition
Let \(\mu\) be a population mean and \(\varepsilon\gt0\) a fixed tolerance. A miss is \(|\bar X_n-\mu|\gt\varepsilon\). The band includes both endpoints. A miss rate in repeated simulations estimates the probability of this event; it need not equal that probability.
The cards use a target of 0.5 and tolerance 0.1. This classifies a single value. It says nothing yet about how the probability changes with sample size.
The sampling rule matters
Independent and identically distributed, or iid, means that all draws share one distribution and that their joint probabilities factor across draws. The population stays fixed as the sample grows. Each run uses fresh draws, and different runs are independent in the probability model. The page approximates that model with a reproducible pseudorandom generator.
Independently sampling with replacement from a fixed population is an example. Copying an observation, selecting only favorable outcomes, or changing the population midway does not follow this rule. The mean and variance below are population quantities, not estimates substituted from the observed sample.
Choose the trend before seeing the runs
- Choose what happens to the miss probability in the long run.
- After checking, move the sample-size control to inspect a checkpoint.
- Draw a new batch to compare simulation noise; Start over clears the reveal.
Read the two plots differently. A path follows one accumulating sample. A point on the miss-rate curve counts across all runs at one fixed size. A run can enter the band and later leave it. Neither the simulated fraction nor the exact probability must decrease at every integer sample size.
The theoretical curve sums binomial probabilities for counts outside the band. It is a finite-sample calculation, not a normal approximation. The simulation is evidence about that calculation; a finite collection of paths cannot prove a statement about every future sample size. A recorded zero means that this batch contained no misses, not that the probability is zero.
Refresher: how the theoretical curve is computed
For independent draws taking values zero and one, each with equal probability, the number of ones \(K_n\) has probabilities
\[P(K_n=k)=\binom nk 2^{-n}.\]The binomial coefficient counts which positions contain ones. Each ordered sequence has the same probability. Since \(\bar X_n=K_n/n\), add the masses whose means are strictly outside the band. Values on the boundary are excluded from this sum. The code compares integer counts before dividing, so numerical rounding cannot misclassify a boundary.
Change the population
Keep independent draws, but use a standard Cauchy population. Its density is \(f(x)=1/[\pi(1+x^2)]\) on the real line. Zero is its symmetry center. Compare the average with that center using the same tolerance.
Symmetry does not make an expectation exist. For a Cauchy variable, the positive and negative contributions to the expectation are both infinite. Subtracting them is undefined. A symmetric principal value is a different operation and cannot supply the mean required by a law of large numbers.
Refresher: the Cauchy facts used here
The Cauchy CDF is \(F(x)=1/2+\arctan(x)/\pi\). Subtract its values at the two band edges to get the probability inside. Its tails are heavy enough that \(E|X|=\infty\): the integral of \(x/(1+x^2)\) over the positive half-line diverges logarithmically.
The average of independent standard Cauchy variables is again standard Cauchy. One way to establish this uses the characteristic function, defined as \(\phi_X(t)=E[e^{itX}]\), where \(i^2=-1\). For this density it is \(e^{-|t|}\). Independence multiplies characteristic functions, so the average has
\[\phi_{\bar X_n}(t)=(e^{-|t|/n})^n=e^{-|t|}.\]A distribution is determined by its characteristic function. These two characteristic-function facts are supplied here; the proof builder below does not require them. The simulation generates Cauchy draws by the inverse CDF, using \(\tan(\pi(U-1/2))\) for a uniform draw strictly between zero and one.
Use what you found above: plan a sample
Return to iid observations with a known finite population variance. Chebyshev applied to the sample mean gives a usable bound:
\[P(|\bar X_n-\mu|\gt\varepsilon)\le\min\left(1,\frac{\sigma^2}{n\varepsilon^2}\right).\]The following goals use variance 0.25 and tolerance 0.1. Find the smallest size on the slider that gives each requested guarantee. The bound is sufficient; it need not be the actual miss probability or the smallest size that works for a particular distribution.
From variance to a vanishing probability
Let \(X_1,X_2,\ldots\) be iid with finite mean \(\mu\) and finite variance \(\sigma^2\). For every fixed \(\varepsilon\gt0\),
\[P(|\bar X_n-\mu|\gt\varepsilon)\longrightarrow0.\]This says that \(\bar X_n\) converges to \(\mu\) in probability. The tolerance is fixed while the sample size tends to infinity. It need not hold for a tolerance that itself shrinks arbitrarily fast.
The weak law needs only iid draws with a finite mean. Finite variance is an extra assumption made here because the proof below uses Chebyshev's inequality; the finite-mean version needs a different argument.
For the proof choices, assume \(n\ge2\) and \(\sigma^2\gt0\), and write \(B_n=\sigma^2/(n\varepsilon^2)\). The zero-variance case is handled below. These restrictions keep the alternative equations distinct.
The expectation and variance rules give the moments of a mean. The Markov and Chebyshev lesson supplies the tail inequality. Choose the valid step at each line.
What the limit says
Given any positive tolerance and any positive probability target, a sufficiently large deterministic sample size makes the miss probability smaller than that target for every larger size. It does not identify the last time a particular path leaves the band. It also does not say that a short observed streak must be followed by compensating outcomes: independent future draws retain their original probabilities.
If the variance is zero, each observation equals its mean with probability one, and so does every finite sample mean. The result is immediate. A single observation also obeys the moment formula, although it is not part of the proof-choice range.
Weak and strong laws: what is different?
The weak law fixes a size and bounds the probability of a miss there. The strong law states that, with probability one, the entire sequence of means converges to the population mean. On such a path, every fixed positive band eventually contains all later averages; the time when that happens may depend on the path.
For iid variables with \(E|X_1|\lt\infty\), both laws hold. Finite variance is sufficient but not necessary. This page proves only the finite-variance weak law with Chebyshev; the stronger integrable version and the strong law are stated for context, not proved by the simulation or the builder. Independence can also be weakened in other theorems, with additional conditions.
Turn assumptions into a guarantee
Use what you found above. Enter a decimal without units. Probability answers accept absolute error 0.0001. The sample-size answer is an exact integer. Each problem includes hints and a worked solution.
Further reading
- S. Ross, A First Course in Probability, chapter 8, “Limit Theorems.”