Last updated 13 November 2026
What is the law of large numbers?
The law of large numbers says that the average of many independent samples from the same distribution gets closer and closer to the true expected value as the number of samples grows. Flip a fair coin ten times and you may see 70% heads; flip it ten thousand times and the share of heads will be very close to 50%. It is the reason sample averages, Monte Carlo estimates and mini-batch gradients can be trusted. On TensorTonic you implement Monte Carlo estimation and the sampling distribution of the mean from scratch, with tests that check your output.
The Law of Large Numbers (LLN) is the anchor of statistics. It states a simple but powerful truth: as you collect more data, the sample average converges to the true expected value.
The Core Promise
Sample mean approaches population mean as sample size grows
Without LLN, machine learning would be impossible. We assume that training loss approximates true generalization error. LLN is the mathematical license for that assumption.
The Casino Intuition
Why Casinos Always Win
Bet on Red (Roulette)
Win: 18/38 = 47.4%
Lose: 20/38 = 52.6%
Expected Value
= -$0.052 per bet
The casino is not gambling. It is running a business based on LLN.
Mathematical Statement
Let be i.i.d. random variables with mean . The sample mean is:
Sample mean = sum of observations divided by count
Law of Large Numbers
As n approaches infinity, the sample mean converges to the true mean:
Interactive: Watch Convergence
Try different distributions and sample sizes. Notice how the running average stabilizes around the true mean as n grows. Small n = noisy. Large n = stable.
Notice how the "swings" (variance) are huge at the start (small N),
but the line inevitably tightens around the True Mean as N grows.
Why It Works: Variance Reduction
The intuition comes from looking at the variance of the sample mean.
Start with variance of sample mean:
For independent variables:
Result:
The Key Insight
As , variance . A random variable with zero variance is a constant. Therefore, the sample mean becomes the constant .
What is the difference between the weak and strong law of large numbers?
The weak law says that, for a large enough sample, the average is very likely to be close to the true mean; the strong law says that the sequence of averages actually converges to the true mean with probability 1. The strong law is the stronger guarantee, because it describes the whole sequence rather than one sample size at a time.
| Weak law | Strong law | |
|---|---|---|
| Type of convergence | In probability | Almost surely |
| What it guarantees | Large deviations become unlikely for large n | The averages converge to the mean with probability 1 |
| Strength | Weaker (implied by the strong law) | Stronger |
Weak LLN
Convergence in Probability
For any margin , probability of being far from goes to zero.
Strong LLN
Almost Sure Convergence
The sample average converges with probability 1.
For most ML applications, the distinction does not matter. Both guarantee convergence.
What is the difference between the law of large numbers and the central limit theorem?
The law of large numbers tells you where the sample mean ends up, which is at the true mean, while the central limit theorem tells you how the sample mean is spread around that value for a finite sample, which is approximately a normal distribution whose width shrinks like one over the square root of the sample size. They describe different aspects of the same process and are often confused.
| Theorem | What it says | Analogy |
|---|---|---|
| LLN | Sample mean converges to true mean | Where the arrow lands (the target) |
| CLT | Distribution of sample means is Normal | The shape of the arrow pattern |
See Central Limit Theorem for the distribution story.
The Gambler's Fallacy
The Mistake
"I got 10 heads in a row. LLN says it balances to 50%, so tails is 'due' next."
Why It's Wrong
The coin has no memory. LLN works by dilution, not compensation.
Example
The streak did not disappear. It just became statistically insignificant.
Interactive: Gambler's Fallacy Demo
Start with a streak of heads, then flip more. Watch how the ratio approaches 50% through dilution, not correction.
Starting with 10 Heads in a row (100%)
Total Stats
Observed: The percentage drops towards 50%, but the absolute number of Heads is still much higher than Tails (diff: 10).
The universe didn't generate extra tails to "fix" the streak. It just buried the streak under a mountain of new, normal data. That is Dilution.
ML Applications
Monte Carlo Methods
Replace intractable integrals with sample averages:
Used in MCMC, Reinforcement Learning (value estimation), Bayesian inference.
Empirical Risk Minimization
Training loss approximates true generalization loss:
The entire justification for training on finite datasets.
Stochastic Gradient Descent
Mini-batch gradient is an unbiased estimate of full gradient. Over many steps, the noise averages out. SGD converges because of LLN.
AlphaGo & MCTS
Cannot compute exact game tree values. Instead, play thousands of random games from a position. Average outcome converges to true value of the position.
Frequently asked questions about the law of large numbers
Why does the sample mean converge to the true mean?
For independent samples with variance σ², the variance of the sample mean is σ²/n, which shrinks toward zero as the sample size n grows. A quantity whose variance goes to zero settles at a constant, and for the sample mean that constant is the true mean μ.
Does the law of large numbers mean a streak will balance out?
No, because a fair coin has no memory, so later flips never compensate for a streak. The law of large numbers works by dilution. After 10 heads in a row, about 1000 more fair flips give roughly 510 heads out of 1010 flips, or 50.5%, so the streak still exists but barely moves the ratio.
Practice this
On TensorTonic you implement this from scratch and test it in the browser.
- Monte Carlo Pi Estimation: watch an average converge as the number of samples grows.
- Sampling Distribution of the Mean: see how sample means spread around the true mean.
- Standard Error Comparison: measure how that spread shrinks with sample size.
- Central Limit Theorem: the companion result about the shape of that spread.