AI Wiki中文/EN

The law of large numbers

大数定律

Show what repeated averaging guarantees, prove a finite-variance bound, and distinguish probability convergence from pathwise convergence.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

More measurements, a steadier average

A fair coin need not produce half heads in ten flips. In fact, the probability that the head fraction differs from one half by at least 0.1 is about 0.754. After one hundred independent flips it is about 0.0569; after two hundred, about 0.00569. These are exact binomial probabilities rounded for display, not simulation results.

The law of large numbers explains why averages concentrate around an expectation under suitable assumptions. It does not promise that the next observation will compensate for previous ones, or that every longer prefix is closer to the mean. The coin has no memory of the imbalance. MIT Introduction to Probability, Lecture 18, slides 6–9

Make “gets closer” precise

Let X1,X2,…X_1,X_2,\ldots be independent and identically distributed real random variables, with E∣X1∣<∞\mathbb E|X_1|<\infty and mean μ\mu. Define X‾n=n−1∑i=1nXi\overline X_n=n^{-1}\sum_{i=1}^nX_i. The weak law says

∀ϵ>0,Pr⁡(∣X‾n−μ∣≥ϵ)⟶0(n⟶∞).\forall\epsilon>0,\qquad \Pr(|\overline X_n-\mu|\geq\epsilon)\longrightarrow0\quad(n\longrightarrow\infty).

This is convergence in probability. Fix an error tolerance first, then ask how likely a sample average is to fall outside it as the sample size grows. The condition on the absolute first moment ensures a finite, well-defined expectation. Finite variance is a stronger sufficient assumption that gives a particularly short proof. MIT 6.436J, Lecture 17, Theorem 3

Assume additionally Var⁡(X1)=σ2<∞\operatorname{Var}(X_1)=\sigma^2<\infty. Linearity of expectation and independence give

E[X‾n]=μ,Var⁡(X‾n)=σ2n.\mathbb E[\overline X_n]=\mu,\qquad \operatorname{Var}(\overline X_n)=\frac{\sigma^2}{n}.

For any nonnegative random variable W, W≥a 1W≥aW\geq a\,\mathbf1_{W\geq a} when a>0a>0. Taking expectations proves Markov’s inequality. Set W=(X‾n−μ)2W=(\overline X_n-\mu)^2 and a=ϵ2a=\epsilon^2 to obtain Chebyshev’s bound:

Pr⁡(∣X‾n−μ∣≥ϵ)≤min⁡(1,σ2nϵ2).\Pr(|\overline X_n-\mu|\geq\epsilon)\leq\min\left(1,\frac{\sigma^2}{n\epsilon^2}\right).

The right side tends to zero, proving the finite-variance weak law. For a fair coin, σ2=1/4\sigma^2=1/4. At n=100 and tolerance 0.1, the bound is 0.25 while the actual probability is about 0.0569. A valid bound can be loose. To make this bound at most δ\delta, it suffices to choose n≥σ2/(δϵ2)n\geq\sigma^2/(\delta\epsilon^2); this is a sufficient sample-size rule, not the smallest possible n.

The strong law makes a statement about whole infinite outcome sequences:

Pr⁡(lim⁡n→∞X‾n=μ)=1.\Pr\left(\lim_{n\to\infty}\overline X_n=\mu\right)=1.

It holds under the same i.i.d. and finite-absolute-first-moment assumptions. Almost every sample path eventually stays within each fixed tolerance, though the time at which this happens depends on the path. This is stronger than inspecting one sample size at a time. The proof above establishes the weak law only; proving the strong law needs another argument. Sheffield, Lecture 32, slides 10–12

Count all coin outcomes without listing them

The program computes the exact probability of a deviation at least epsilon for a fair-coin mean. A recurrence generates the integer binomial coefficients, and Fraction keeps the boundary comparison exact. No random seed or simulated path is involved.

from fractions import Fraction as F

def fair_coin_tail(n, epsilon):
    if type(n) is not int or not 1 <= n <= 2000 or not isinstance(epsilon,F) or epsilon <= 0:
        raise ValueError("integer n in [1,2000] and positive Fraction epsilon required")
    count = 0
    coefficient = 1
    for k in range(n+1):
        if abs(F(k,n)-F(1,2)) >= epsilon:
            count += coefficient
        if k<n:
            coefficient = coefficient*(n-k)//(k+1)
    exact = F(count,2**n)
    bound = min(F(1),F(1,4)/(n*epsilon**2))
    return exact,bound

for n in [10,50,100,200]:
    probability,bound = fair_coin_tail(n,F(1,10))
    assert probability <= bound
    print(n,round(float(probability),6),float(bound))
assert fair_coin_tail(10,F(1,10))[0] == F(193,256)
assert fair_coin_tail(100,F(1))[0] == 0
assert fair_coin_tail(5,F(1,2))[0] == F(1,16)

There are n+1 count states instead of 2n2^n ordered sequences. The loop uses O(n)O(n) integer/rational steps and a constant number of accumulator objects. Those objects are not constant-size machine words: binomial coefficients need O(n)O(n) bits, and exact arithmetic has additional bit complexity. The n cap keeps this teaching calculation modest.

Flips nExact tail, roundedChebyshev upper bound
100.7539061.000000
500.2026390.500000
1000.0568880.250000
2000.0056850.125000

These selected values illustrate concentration. They do not prove that an exact discrete tail decreases at every consecutive n; event boundaries move as the count grid changes.

Averaging cannot remove shared bias

If every measurement equals the same random Z, all observations share its noise and their average remains Z. Independence has failed. For measurements satisfying the stated i.i.d. and finite-absolute-first-moment conditions, adding a fixed calibration bias b shifts the limiting average from the intended mean to that mean plus b. More samples do not fix that target mismatch.

Infinite-variance distributions need not defeat every law of large numbers: i.i.d. variables with a finite absolute first moment still satisfy the laws stated above. What fails is the finite-variance Chebyshev proof and its rate. When the expectation itself is undefined, there may be no finite mean for averages to estimate. Dependent observations can obey other laws under suitable conditions, but the i.i.d. proof cannot simply be reused.

The law describes a sample mean, not the shape of individual observations. A histogram with fixed bins can be studied by applying the law to bin-membership indicators. Letting the number or width of bins change requires additional analysis; a vague histogram resemblance is not the theorem.

What does “enough samples” buy?

  1. With variance four, tolerance 0.2 and tail bound 0.05, what n suffices by Chebyshev? Answer: n≥4/(0.05⋅0.22)=2000n\geq4/(0.05\cdot0.2^2)=2000.
  2. If the first nine fair flips are heads, is the next flip more likely tails? Answer: no; independence leaves each probability at one half.
  3. Does the weak-law proof given here prove almost-sure convergence? Answer: no. It bounds each fixed-n event, without establishing a statement about all sufficiently late n along almost every path.
  4. Does an infinite variance automatically rule out the i.i.d. strong law? Answer: no; a finite absolute first moment suffices, though the displayed variance bound is unavailable.

From averages to uncertainty estimates

Sample losses, Monte Carlo averages, and empirical frequencies all use this logic. A trustworthy application names the quantity being averaged and checks the sampling assumptions. The central limit theorem studies the distribution of properly rescaled fluctuations; covariance explains why shared variation can prevent the familiar variance reduction.

Make a prediction, then check

The first nine fair-coin flips are heads. What is the probability of tails next?

Choose one answer

Learning objectives

  • Derive the finite-variance law and a sufficient sample size using Markov and Chebyshev inequalities.
  • Distinguish convergence in probability from almost-sure convergence, and random error from shared noise and systematic bias.

Prerequisites & connections

Explore related knowledge →

References

  1. Introduction to Probability — Lecture 18: Inequalities, Convergence, and the Weak Law of Large Numbers
    John Tsitsiklis; Patrick Jaillet; MIT OpenCourseWare · 2018
  2. Fundamentals of Probability — Lecture 17: Laws of Large Numbers and Central Limit Theorem
    Yury Polyanskiy; MIT OpenCourseWare · 2018
  3. Probability and Random Variables — Lecture 32: Strong law of large numbers and Jensen’s inequality
    Scott Sheffield; MIT OpenCourseWare · 2014

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-05 · Codex multi-agent technical check: primary-source verification, derivation and numerical assertions, bilingual comparison, and review by another agent or the parent; no independent human peer review.

  • Enumerated every coin sequence for n=1 through 12 and four rational tolerances, checking tails and boundaries; separately verified variance reduction and Chebyshev bounds with eight exact convolutions.
  • Checked weak/strong quantifiers and proof scope; did not copy a lecture typo replacing the strong-law average with Xn, and did not claim monotone convergence of observed averages.
  • A second Codex agent independently reviewed the chapter; the fixed-bias example was tightened to retain i.i.d. and integrability assumptions.
  • The parent executed all 25 independent probability checks; bilingual code, display equations, main anchors, sources and exercises were additionally compared.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.