Foundations to Frontier
Tests
A. Mathematical Foundations › A4 Probability Theory › Theory

Law of Large Numbers (Weak and Strong)

Why averaging works. The weak law says the sample mean is unlikely to be far from the true mean once n is large (Chebyshev gives a one-line proof); the strong law says each run's average actually converges. Together they justify Monte Carlo estimation, empirical risk minimization, policy evaluation by rollouts and the empirical CDF. You will also see where averaging fails (the Cauchy), why errors shrink only like 1/√n, and why stochastic approximation needs decaying step sizes.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Flip a coin many times

Flip a coin 10 times and you might get 7 heads: 70%. Flip it 10,000 times and you’ll get very close to 50% heads. It’s never exact, but closer and closer the more you flip. This is the law of large numbers: the average of many independent tries settles down to the true average.

It’s why casinos always win in the long run, why insurance works, and why a robot can learn how long a task takes by averaging many attempts.

Averages settle down: the law of large numbers
3.5n (log scale)
At n = 1995: 0% of paths are outside μ ± 0.20 (Chebyshev bound 3.7%).
Each coloured line is one experiment's running average X̄ₙ. Green band: μ ± ε. Dashed: μ ± 2σ/√n, the typical size of the error. The weak LLN says the share of paths outside the band tends to 0. The strong LLN says each path eventually enters and stays. The Pareto(1.5) still obeys the LLN (it has a mean), but rare huge jumps make convergence slow. Press to rerun.
Why engineers care

Monte Carlo simulation, training a network on a dataset, estimating a robot policy’s success rate from trials, and calibrating a sensor by repeated measurements all rest on one promise: averages of many samples approach the true expectation. The LLN is that promise, and its conditions tell you when it breaks.

📝 Quick check (Level 0)
0/3 answered
  1. 1. After 10,000 fair coin flips, the fraction of heads is…
  2. 2. Averaging more independent measurements makes the average…
  3. 3. The LLN is about the average of…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Statement

Let X1,X2,…X_1, X_2, \dots be iid with mean μ\mu, and let Xˉn=1n∑i=1nXi\bar X_n = \frac1n\sum_{i=1}^nX_i.

  • Weak LLN: for every ε>0\varepsilon > 0, P(∣Xˉn−μ∣>ε)→0P(\lvert\bar X_n - \mu\rvert > \varepsilon)\to0. This is convergence in probability.
  • Strong LLN: P(Xˉn→μ)=1P(\bar X_n\to\mu) = 1. Each run’s average converges, almost surely.

How fast? Like 1/√n

If Var⁡X=σ2\operatorname{Var}X = \sigma^2, then EXˉn=μ\mathbb E\bar X_n = \mu and Var⁡Xˉn=σ2/n\operatorname{Var}\bar X_n = \sigma^2/n. The typical error is the standard error σ/n\sigma/\sqrt n. Ten times more accuracy costs a hundred times more samples. This holds in any dimension, which is why Monte Carlo beats grids in high dimensions.

Monte Carlo integration

∫01f(x) dx=E[f(U)]≈1n∑i=1nf(Ui)\int_0^1f(x)\,dx = \mathbb E[f(U)]\approx\frac1n\sum_{i=1}^nf(U_i)

Estimating π\pi by throwing darts at a square is the classic example.

📝 Quick check (Level 1)
0/3 answered
  1. 1. Var(X̄ₙ) =
  2. 2. To halve a Monte Carlo error you need about…
  3. 3. The strong LLN is about convergence…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 45 minUndergraduate students and practising engineers.

Proof of the weak law (finite variance)

Chebyshev’s inequality (A4.3-6) gives

P(∣Xˉn−μ∣>ε)≤Var⁡Xˉnε2=σ2nε2→0P(\lvert\bar X_n - \mu\rvert > \varepsilon)\le\frac{\operatorname{Var}\bar X_n}{\varepsilon^2} = \frac{\sigma^2}{n\varepsilon^2}\to0

That’s the whole proof. It also gives a (loose) sample size: n≥σ2/(δε2)n\ge\sigma^2/(\delta\varepsilon^2) guarantees P(error>ε)≤δP(\text{error} > \varepsilon)\le\delta. Only uncorrelated samples with bounded variance are needed, not full independence.

When averaging fails

  • No mean. For the Cauchy, Xˉn\bar X_n has the same distribution as one sample (A4.3-3). Averaging gives you nothing.
  • Infinite variance. A Pareto with 1<α≤21<\alpha\le2 still obeys the LLN, but convergence is slow and erratic, because rare huge values dominate. Heavy-tailed costs (rare catastrophic failures) are exactly where naive averaging misleads.
  • Dependence. Correlated samples, such as consecutive frames or MCMC chains, reduce the effective sample size to neff=n/(1+2∑kρk)n_{\text{eff}} = n/(1 + 2\sum_k\rho_k).

What it justifies in ML

Empirical risk R^(h)=1n∑ℓ(h(xi),yi)→R(h)=Eℓ\hat R(h) = \frac1n\sum\ell(h(x_i), y_i)\to R(h) = \mathbb E\ell for each fixed hh. Learning theory needs this uniformly over a class of hh. The simplest uniform LLN is Glivenko–Cantelli, sup⁡x∣Fn(x)−F(x)∣→0\sup_x\lvert F_n(x) - F(x)\rvert\to0 a.s., with the explicit DKW rate (Practice Code 5).

🐍 Exercise 1: the weak law in action
Estimate P(|X̄ₙ − μ| > ε) by simulation for a die at n = 10, 100 and 1000. Compare it with Chebyshev's bound, compute running means, and check that Monte Carlo π error shrinks like 1/√n.
📝 Quick check (Level 2)
0/3 answered
  1. 1. The weak LLN follows in one line from…
  2. 2. The mean of 1000 standard Cauchys is…
  3. 3. Correlated samples have an effective sample size that is…

Level 3: Advanced

★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.

Proof of the strong law (finite fourth moment)

Assume EX4<∞\mathbb E X^4<\infty, and centre so μ=0\mu = 0. Let Sn=∑XiS_n = \sum X_i.

  1. Fourth moment of the sum. Expand ESn4\mathbb ES_n^4. Terms with any index appearing once vanish. What’s left is n EX4+3n(n−1)σ4≤Cn2n\,\mathbb EX^4 + 3n(n - 1)\sigma^4\le Cn^2.
  2. Markov’s inequality. P(∣Xˉn∣>ε)=P(Sn4>n4ε4)≤Cn2ε4P(\lvert\bar X_n\rvert > \varepsilon) = P(S_n^4 > n^4\varepsilon^4)\le\frac{C}{n^2\varepsilon^4}.
  3. Borel–Cantelli. ∑nC/(n2ε4)<∞\sum_nC/(n^2\varepsilon^4)<\infty, so with probability 1 only finitely many of the events {∣Xˉn∣>ε}\{\lvert\bar X_n\rvert > \varepsilon\} occur.
  4. Conclude. Take ε=1/k\varepsilon = 1/k for every kk (a countable intersection of probability-1 events): Xˉn→0\bar X_n\to0 almost surely. ∎

Etemadi (1981) proved the strong law assuming only E∣X∣<∞\mathbb E\lvert X\rvert<\infty and pairwise independence. Kolmogorov’s version says that for iid variables, E∣X∣<∞\mathbb E\lvert X\rvert<\infty is also necessary.

Borel–Cantelli lemma

If ∑P(An)<∞\sum P(A_n)<\infty then P(An infinitely often)=0P(A_n\text{ infinitely often}) = 0. Proof: P(⋃m≥nAm)≤∑m≥nP(Am)→0P(\bigcup_{m\ge n}A_m)\le\sum_{m\ge n}P(A_m)\to0. Conversely, if the AnA_n are independent and ∑P(An)=∞\sum P(A_n) = \infty, then P(An i.o.)=1P(A_n\text{ i.o.}) = 1.

Weak vs strong

The weak law allows each path to make rare excursions forever, as long as they become less likely at each fixed nn. The strong law forbids that: eventually every path stays within ε\varepsilon. A4.3-8 gives an example that converges in probability but not almost surely.

Exercise 3.1: Show Var(X̄ₙ) = σ²/n needs only uncorrelated samples

Var⁡∑Xi=∑iVar⁡Xi+∑i≠jCov⁡(Xi,Xj)=nσ2\operatorname{Var}\sum X_i = \sum_i\operatorname{Var}X_i + \sum_{i\ne j}\operatorname{Cov}(X_i, X_j) = n\sigma^2 when all covariances are 0. Divide by n2n^2.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Borel–Cantelli: if Σ P(Aₙ) < ∞ then…
  2. 2. The 4th-moment proof bounds P(|X̄ₙ| > ε) by…
  3. 3. For iid samples, the strong LLN needs…

Level 4: Expert

★★★★★ Expert⏱ 45 minResearchers: original papers and open problems.

Stochastic approximation: averaging online

A robot learns the expected energy of a mission by updating xn+1=xn+an(Yn−xn)x_{n+1} = x_n + a_n(Y_n - x_n) after each rollout YnY_n. With an=1/na_n = 1/n this is exactly the running mean, so the strong LLN applies. Robbins and Monro (1951) showed convergence whenever ∑an=∞\sum a_n = \infty (you can always move far enough) and ∑an2<∞\sum a_n^2<\infty (the noise eventually averages out). A constant step size never converges: it settles into a noise floor with variance aσ2/(2−a)a\sigma^2/(2 - a). That’s a feature when the environment drifts. These are the same conditions behind SGD, TD learning and Q-learning (Sutton and Barto, 2018).

🐍 Exercise 2 (research): Robbins–Monro step sizes for policy evaluation
Average 20,000 noisy mission-energy rollouts with Robbins–Monro. Show that a_n = 1/n reproduces the sample mean exactly, a constant step stalls at a noise floor of variance aσ²/(2 − a), and a_n = n^−0.6 converges. Then check the strong LLN: the worst deviation from step n onward shrinks.

The LLN in AI, robotics and aerospace

  • Policy evaluation. Monte Carlo returns averaged over episodes converge to the value function (first-visit MC). TD learning is a stochastic-approximation version of this.
  • Empirical risk minimization is justified by uniform laws of large numbers over the hypothesis class (Vapnik, 1998). Without uniformity, overfitting breaks the link between training and test error.
  • Particle filters approximate posterior expectations with weighted averages over particles. The LLN for interacting particle systems makes them consistent as the particle count grows (Del Moral, 2004).
  • Reliability demonstration. Estimating a failure rate from trials converges, but slowly for rare events: you need on the order of 1/p1/p trials just to see one failure. That motivates importance sampling (A4.3-1).
  • MCMC relies on ergodic theorems, LLNs for dependent Markov-chain samples (A4.4-1). The effective sample size quantifies how much the dependence costs.

References

  1. R. Durrett (2019). Probability: Theory and Examples, 5th ed., Ch. 2. Cambridge University Press.
  2. J. Bernoulli (1713). Ars Conjectandi. Basel.
  3. A. N. Kolmogorov (1933). Grundbegriffe der Wahrscheinlichkeitsrechnung. Springer.
  4. N. Etemadi (1981). “An elementary proof of the strong law of large numbers.” Z. Wahrscheinlichkeitstheorie, 55.
  5. H. Robbins, S. Monro (1951). “A stochastic approximation method.” Annals of Mathematical Statistics, 22(3).
  6. A. Dvoretzky, J. Kiefer, J. Wolfowitz (1956). “Asymptotic minimax character of the sample distribution function.” Annals of Mathematical Statistics, 27(3); constant fixed by P. Massart (1990), Annals of Probability, 18(3).
  7. V. Vapnik (1998). Statistical Learning Theory. Wiley.
  8. R. Sutton, A. Barto (2018). Reinforcement Learning: An Introduction, 2nd ed. MIT Press.
  9. P. Del Moral (2004). Feynman–Kac Formulae: Genealogical and Interacting Particle Systems. Springer.
  10. H. Kushner, G. Yin (2003). Stochastic Approximation and Recursive Algorithms and Applications, 2nd ed. Springer.