Law of Large Numbers, Central Limit Theorem & Bounds
Why casinos never lose, why cutting A/B error in half costs 4× the users, watching crazy shapes become bell curves, and Hoeffding guarantees
You ran a poll of 1,000 voters and got a ±3% margin of error. Your boss says: 'Cut that margin of error in HALF to ±1.5%!' How many total voters do you need to survey?
- Feel the difference between LLN (your running average settles on the true mean) and CLT (the shape of sample-mean errors becomes a bell curve).
- Understand the √n Law: why cutting uncertainty in half ALWAYS requires 4× more data.
- Size real A/B tests and build 95% confidence intervals without black-box calculators.
- Use Markov, Chebyshev, and Hoeffding inequalities to guarantee finite-sample bounds even when you know nothing about the curve's shape.
Have you ever wondered how a casino knows its yearly profit to within 1%, even though every single spin of the roulette wheel is totally random? Or how a poll of just 1,000 people predicts an election of 150 million voters? Two twin miracles make it work:
- Law of Large Numbers (LLN): Individual spins are chaotic, yet the average locks onto the true mean !
- Central Limit Theorem (CLT): Even if raw data looks hideous and lopsided, the averages form a clean Gaussian bell curve!
1. Law of Large Numbers (LLN) — Watch Randomness Settle Down!
Suppose you flip a fair coin 5 times and get 4 Heads (80%!). Nobody calls the police — small samples are super noisy! Now flip that same coin 500 times: getting 80% Heads (400 out of 500) is practically impossible — your running percentage gets trapped inside a narrowing funnel around 50.0%!
Watch it happen right now with your own clicks in the Live Running Average Racer below!
Why Sample Averages Funnel In at Speed
Suppose each observation has mean and variance . Take the average of independent observations :
- Center stays exact: (unbiased!).
- Variance shrinks by : .
- Standard Error shrinks by : !
As , the wobble collapses to zero — guaranteeing (Law of Large Numbers)!
Watch how wildly the blue running average swings during the first 10 flips — then click +200 Flips to watch it lock tightly onto the dashed green 50.0% line!
An A/B test with n = 500 users per arm has a standard error of 2.0 percentage points. How many users per arm do you need to shrink the standard error to 0.5 percentage points?
2. Central Limit Theorem (CLT) — Why Bell Curves Rule the World
Imagine tasting soup from a giant pot. One raw spoonful might have a giant potato chunk or just broth (super skewed!). Yet if you scoop 30 spoonfuls and measure the average saltiness, repeat that 1,000 times, and plot a histogram of those 1,000 averages... BOOM — a textbook symmetric Gaussian bell curve appears out of thin air, even if the original data was flat, skewed, or U-shaped!
The Central Limit Theorem in Plain English
Take ANY i.i.d. data with finite mean and finite spread . Once is reasonably large ( is the classic rule of thumb), the sample mean behaves like a Gaussian bell curve:
Instant A/B Test Sizing & 95% Confidence Intervals
Because 95% of a Gaussian lies inside , we get two priceless workplace tools:
- 95% Confidence Interval:
- A/B Test Sample Size per Arm (80% power, 5% significance, baseline , lift ):
Sizing a Real Checkout A/B Test in 30 Seconds
Your e-commerce checkout converts 10% of visitors (p = 0.10). Your product manager wants to detect a 1 percentage point lift (from 10% to 11%, so δ = 0.01) with 80% power and 95% confidence. How many users per arm do you need?
Each user is a Bernoulli() coin flip, so per-user variance is:
Pause & Check (Classic Interview Trap!): You have a heavily right-skewed income dataset with n = 100,000 people. According to the Central Limit Theorem, what becomes a Gaussian bell curve?
3. Finite-Sample Safety Nets: Markov, Chebyshev & Hoeffding
What if your boss says: "Don't tell me 'approximately Gaussian when n is big' — I only have n = 50 bounded data points and I need a 100% MATHEMATICAL GUARANTEE on worst-case error!"
Welcome to Concentration Inequalities — three safety nets ranked from loosest (needs almost no info) to exponentially tightest:
- Markov's Inequality (knows ONLY that and its average ): (Intuition: if average salary is $50k, at most 1/5 = 20% of people can earn $250k+ — otherwise the average alone would already exceed $50k!)
- Chebyshev's Inequality (knows Mean + Variance ):
- Hoeffding's Inequality (knows values are i.i.d. inside — exponentially tight!):
The mathematical backbone of PAC Machine Learning generalization bounds and UCB Multi-Armed Bandits!
Chance that your sample average misses the true mean by MORE than error tolerance t.
All scores on a test are ≥ 0, and the class average is 20 points. Using ONLY Markov's Inequality, what is the MAXIMUM possible fraction of students who scored 80 or higher?
The exact honest questions almost every beginner wonders — answered in plain English without hiding behind jargon.
- LLN tells you WHERE the sample average goes (it locks onto ).
- CLT tells you WHAT SHAPE the wobble around has (a Gaussian bell curve of width )!
Watch Any Crazy Distribution Morph into a Bell Curve
Slide n from 1 to 30! Notice two simultaneous miracles: the shape becomes a symmetric Gaussian bell curve AND the spread shrinks by 1/√n.
Mini-Batch SGD Gradient Noise
Averaging gradients over a mini-batch of size B shrinks gradient noise standard deviation by 1/√B (pure LLN/CLT!).
A/B Testing & Experimentation Platforms
Every z-test, p-value, and 95% confidence interval at Google/Meta/Netflix is powered directly by CLT.
UCB1 Bandit Exploration Bonus
Upper Confidence Bound algorithms compute their √(2 ln t / n_a) exploration bonus by inverting Hoeffding's Inequality!
PAC Learning Generalization Bounds
Hoeffding + Union Bound proves why training error stays close to test error once training data n scales cleanly with model complexity.
import math
import numpy as np
# 1. Watch heavily skewed Exponential data morph into a Gaussian under CLT!
rng = np.random.default_rng(0)
for n in (1, 5, 30):
means = rng.exponential(scale=1.0, size=(20_000, n)).mean(axis=1)
skew = float(np.mean(((means - means.mean()) / means.std()) ** 3))
print(f"n={n:2d}: std={means.std():.3f} (1/√n={1/math.sqrt(n):.3f}) | skewness={skew:.3f} -> 0!")
# 2. A/B Test Sample Size per Arm (baseline p=0.10, lift delta=0.01)
p, delta = 0.10, 0.01
n_per_arm = math.ceil(2 * p * (1 - p) * (1.96 + 0.84) ** 2 / (delta ** 2))
print(f"Users needed per arm: {n_per_arm:,}")