The Central Limit Theorem
The central limit theorem (CLT) is the reason the normal distribution is everywhere. It says that the sum of many independent random variables, whatever their individual distribution, is approximately normal. Dice, waiting times, measurement errors: add enough of them and the bell curve appears.
Statement
Let be independent with the same distribution, mean and finite variance . Let . Then for all ,
Equivalently, the average is approximately normal with mean and standard deviation . The law of large numbers says ; the CLT says the error is about times a standard normal.
The Bernoulli case is the special case where each is 0 or 1. A proof for the general case uses moment generating functions: the MGF of the standardized sum tends to , the MGF of the standard normal.
Watching it happen
Start from a very non-normal distribution, the exponential (skewed, all mass on one side), and standardize sums of copies. Compare quantiles with those of the standard normal:
import numpy as np
rng = np.random.default_rng(1)
normal_q = np.array([-1.645, -1.0, 0.0, 1.0, 1.645]) # 5%, 16%, 50%, 84%, 95% quantiles
print("normal quantiles: ", normal_q.tolist())
for n in [1, 5, 30, 200]:
S = rng.exponential(1.0, size=(100_000, n)).sum(axis=1)
Z = (S - n) / np.sqrt(n) # mean n, sd sqrt(n)
q = np.quantile(Z, [0.05, 0.16, 0.5, 0.84, 0.95])
print(f"n={n:3d} sum quantiles: ", np.round(q, 3).tolist())normal quantiles: [-1.645, -1.0, 0.0, 1.0, 1.645]
n= 1 sum quantiles: [-0.949, -0.824, -0.309, 0.819, 1.978]
n= 5 sum quantiles: [-1.357, -0.964, -0.159, 0.953, 1.846]
n= 30 sum quantiles: [-1.526, -0.981, -0.055, 0.986, 1.739]
n=200 sum quantiles: [-1.604, -0.996, -0.018, 0.991, 1.676]
For the quantiles are far from normal (the median is below the mean, the left tail is cut off at ). By they are close, and by very close. Skewed distributions need larger than symmetric ones; the uniform is close to normal already at (Sums of Continuous Variables).
The CLT for the mean of any data
The CLT applies to sample means of any data source with finite variance, which is why the sampling distribution of the mean is approximately normal even for skewed populations. The Statistics course uses this for confidence intervals and tests.
import numpy as np
rng = np.random.default_rng(2)
# a weird population: 70% zeros, 20% values around 5, 10% values around 50
def draw(size):
u = rng.random(size)
return np.where(u < 0.7, 0.0, np.where(u < 0.9, rng.normal(5, 1, size), rng.normal(50, 10, size)))
pop = draw(1_000_000)
mu, sigma = pop.mean(), pop.std()
n = 100
means = draw((50_000, n)).mean(axis=1)
z = (means - mu) / (sigma / np.sqrt(n))
print("population mean and sd:", round(mu, 3), round(sigma, 3))
print("sd of sample means:", round(means.std(), 4), " sigma/sqrt(n):", round(sigma / np.sqrt(n), 4))
print("P(|Z| < 1.96) for sample means:", round(np.mean(np.abs(z) < 1.96), 4), " normal: 0.95")population mean and sd: 6.004 15.149
sd of sample means: 1.5151 sigma/sqrt(n): 1.5149
P(|Z| < 1.96) for sample means: 0.9515 normal: 0.95
When the CLT fails
- Infinite variance: sums of Cauchy or Pareto variables with are not asymptotically normal; they converge to other "stable" laws, with heavy tails.
- Strong dependence: sums of correlated variables can behave differently; the CLT has versions for weakly dependent sequences, but not for all.
- Small with skew: the approximation can be poor in the tails, which matters for rare events.
In software
The CLT justifies normal-based error bars on benchmarks (average many runs), confidence intervals in A/B tests, and the use of Gaussian noise models. It is also why the averaged gradient of a large mini-batch is roughly normal around the true gradient, a fact used in the theory of stochastic gradient descent.
Exercises
Exercise 1: Sum of dice
Approximate the probability that the sum of 100 dice is at least 370.
Answer
About 0.12.
Solution
Mean 350, standard deviation . With continuity correction, , and .
Exercise 2: Waiting times
A process has 50 independent stages, each exponential with mean 2 seconds. Approximate the probability that the total exceeds 120 seconds.
Answer
About 0.08.
Solution
Total mean 100, variance , standard deviation . , and . (The exact gamma probability is about 0.084: the right tail is a little heavier than normal.)
Exercise 3: Check Exercise 2 (code)
Simulate the total of 50 exponential stages 200,000 times and estimate the probability of exceeding 120.
Answer
About 0.085 (the exact value is 0.0844), slightly above the normal approximation.
Solution
import numpy as np
rng = np.random.default_rng(3)
T = rng.gamma(shape=50, scale=2.0, size=200_000) # sum of 50 exponentials with mean 2
print(round((T > 120).mean(), 4))0.0856
Test yourself
The CLT requires the summed variables to have…
- a normal distribution
- finite variance (and be independent, identically distributed)
- a symmetric distribution
- integer values
The average of i.i.d. variables with standard deviation is approximately normal with standard deviation…