Central Limit Theorem

The Law of Large Numbers tells us that the sample mean converges to the true mean. But it does not tell us how the sample mean is distributed around that mean. The Central Limit Theorem (CLT) answers this question, and its answer is one of the most remarkable results in all of mathematics: the distribution is approximately normal, no matter what the original distribution looks like.

The example program for this chapter is in the file 07_central_limit_theorem.lisp.

A Brief History

The Central Limit Theorem has a long and distinguished history. The earliest form was proved by Abraham de Moivre in 1733 for the special case of Bernoulli trials: he showed that the binomial distribution is well approximated by a normal distribution for large n. Pierre-Simon Laplace generalized De Moivre’s result in his monumental Theorie Analytique des Probabilites (1812) and applied it to problems in astronomy and geodesy, where he needed to reason about the distribution of averaged measurement errors.

The modern general form of the CLT, allowing arbitrary distributions with finite variance, was proved by the Russian mathematician Aleksandr Lyapunov in 1901. Later, the theorem was refined to handle non-identically-distributed variables under a technical condition known as the Lindeberg condition. Even today, generalizations of the Central Limit Theorem are an active area of research, especially for weakly dependent variables and high-dimensional problems.

The Theorem

Let Code Test be i.i.d. random variables with mean Code Test and finite variance Code Test. Let Code Test be their sum. The CLT says that for large Code Test, the standardized sum:

math

converges in distribution to the standard normal distribution Code Test.

Equivalently, the sample mean Code Test is approximately Code Test for large Code Test. Notice that the variance of Code Test shrinks as Code Test: more data means a tighter distribution around the mean. But the CLT tells us more than the LLN did: it tells us the shape of the distribution of Code Test, not just that it concentrates.

Written as a limit of CDFs, the CLT says:

math

where Code Test is the CDF of the standard normal. This mode of convergence is called convergence in distribution or weak convergence. It is the weakest of the modes we surveyed in the previous chapter, and even so, it delivers enormous practical value.

Why This Is Remarkable

The CLT says that the original Code Test can have any distribution with finite variance, and the sum will still become approximately normal. The Code Test could be Bernoulli, uniform, exponential, or some weird custom distribution. It does not matter. Sums of enough i.i.d. random variables always tend toward the normal distribution.

This is why the normal distribution appears everywhere in nature. Many natural quantities are sums or averages of many small independent effects. Heights, measurement errors, blood pressure, and countless other quantities are approximately normal because they are built from the sum of many independent contributions.

The result is worth savoring. A theorem that starts with almost no assumptions about the Code Test except finite variance ends with a very specific conclusion: the standardized sum is a standard normal. It is almost as if the normal distribution is the mathematical shadow of independence and averaging.

Why It Is True: A Sketch via Generating Functions

The moment generating function from Chapter 3 gives a clean way to see why the normal appears, not just that it does. Standardize the individual variables by writing Code Test, so each Code Test has mean Code Test and variance Code Test. The standardized sum is

math

Because the Code Test are independent, the MGF of Code Test is the Code Test-th power of one scaled MGF:

math

Now expand Code Test near Code Test. Since Code Test, Code Test, and Code Test, the Taylor expansion is Code Test. Substituting Code Test and raising to the Code Test-th power,

math

The limit Code Test is exactly the MGF of the standard normal (set Code Test, Code Test in the normal MGF of Chapter 5). Since the MGF determines the distribution, Code Test converges to Code Test. The whole theorem comes down to one fact: only the first two moments survive the Code Test scaling. Every distribution with finite variance has the same quadratic leading behaviour, so they all flow to the same bell curve. The Code Test in the denominator is forced, being the unique scaling that holds the variance of Code Test at Code Test; divide by Code Test and you get the constant Code Test of the Law of Large Numbers, divide by less and the variance blows up. A fully rigorous proof replaces the MGF with the characteristic function Code Test, which exists for every distribution, but the algebra is the same.

Rate of Convergence: Berry-Esseen

The plain CLT is a limit statement: it does not tell us how large Code Test has to be for the normal approximation to be accurate. The Berry-Esseen theorem provides a quantitative bound. Under the additional assumption that the Code Test have finite third absolute moment Code Test, the maximum difference between the CDF of the standardized sum and the standard normal CDF satisfies:

math

for some absolute constant Code Test (the best known universal value is about Code Test; the bound Code Test is due to Shevtsova, 2011) and where Code Test. The error shrinks as Code Test, the same rate we saw in the Law of Large Numbers. Doubling Code Test improves the CLT approximation by a factor of Code Test, roughly Code Test.

The key qualitative message is that the approximation works better when:

  • The original distribution is nearly symmetric (small third moment).
  • The variance is well-behaved (not too small relative to the third moment).
  • The sample size Code Test is large.

For heavy-tailed distributions or highly skewed distributions, the convergence can be quite slow, and much larger samples may be needed before the normal approximation is trustworthy.

The Simulation

The program demonstrates the CLT with a deliberately non-normal source: a Code Test distribution, which takes only the values Code Test and Code Test. This is about as far from a bell curve as you can get. We draw sample means of size Code Test and collect Code Test of them:

1 (defun sample-mean (p n)
2   "M_n = average of n i.i.d. Bernoulli(p)."
3   (/ (loop for i below n sum (bernoulli p)) n 1.0d0))
4 
5 (defun collect-sample-means (p n num-samples)
6   "Collect NUM-SAMPLES independent sample means, each from n Bernoulli(p)
7    trials."
8   (loop for s below num-samples collect (sample-mean p n)))

The CLT predicts that these sample means should have:

  • Mean Code Test
  • Variance Code Test

The program computes both the theoretical predictions and the empirical values from the simulation, then prints a text histogram.

Running the Example

 1 === Central Limit Theorem ===
 2 Source distribution: Bernoulli(p=0.5), very non-normal.
 3 Sample size n = 50, number of sample means = 10000
 4 
 5 CLT predicts for the sample mean M_n:
 6   E[M_n]        = mu        =  0.5
 7   Var(M_n)      = sigma^2/n = 0.0050
 8 Empirical from simulation:
 9   mean of M_n's = 0.4996
10   var  of M_n's = 0.0051
11   (These should be close to the CLT predictions.)
12 
13 Histogram of sample means (bell-shaped = CLT at work):
14    0.274 | *
15    0.300 | *
16    0.328 | ***
17    0.355 | ****
18    0.382 | *******
19    0.409 | **********************
20    0.435 | ******************
21    0.463 | **********************
22    0.490 | **************************************************
23    0.516 | *************************
24    0.544 | *********************
25    0.571 | ********************************
26    0.598 | *********
27    0.625 | ******
28    0.652 | ******
29    0.679 | *
30    0.706 | *
31    0.733 | *
32    0.760 | *
33    0.787 | *

Look at that histogram. It is bell-shaped, even though the source distribution has only two possible values. The CLT has transformed a highly non-normal distribution into a nearly normal one, just by averaging Code Test independent draws.

The empirical mean (Code Test) and variance (Code Test) are very close to the CLT predictions of Code Test and Code Test. The small deviation in the mean is normal sampling variability. The program reseeds its random state on each run, so your exact numbers and bar heights will differ, but the bell shape and the match to the predictions are the same every time.

The Theoretical Basis for Statistical Practice

The CLT is the foundation for much of classical statistics. Confidence intervals, hypothesis tests (z-tests, t-tests), and regression analysis all rely on the normal approximation that the CLT provides.

Confidence Intervals

Suppose we sample Code Test i.i.d. values with unknown mean Code Test and known standard deviation Code Test. By the CLT, the sample mean Code Test is approximately Code Test. A 95% confidence interval for Code Test is:

math

The number Code Test is the 97.5th percentile of the standard normal (the two-sided critical value for 95% coverage). This interval is constructed so that in 95% of hypothetical repetitions of the experiment, the true mean would lie inside. The width of the interval shrinks as Code Test, the familiar Monte Carlo scaling.

Margin of Error in Polling

When a pollster reports a “margin of error” of plus or minus 3%, that number comes from the CLT. The sample proportion is approximately normal (by the CLT), and the margin of error is about Code Test standard deviations of that normal distribution. For a sample of Code Test voters, the margin of error is approximately Code Test in percentage points, ignoring some multiplicative constants.

This is why pollsters usually collect around Code Test respondents. With Code Test, the margin of error is roughly Code Test percentage points. To halve it, they would need Code Test. To reach a margin of error of Code Test percentage points, they would need Code Test, which is prohibitively expensive for most polls.

Quality Control

When a quality control engineer tests whether a manufacturing process is within spec, the CLT justifies using normal-based control charts even when the underlying process distribution is not normal. As long as the daily quantity being tracked is an average of many small independent effects, the CLT guarantees it will be approximately normal.

How Large Does n Need to Be?

A common rule of thumb is that Code Test is sufficient for the normal approximation to be reasonable. But this depends on the shape of the original distribution. For symmetric distributions, Code Test or even Code Test may be enough. For highly skewed distributions, you may need Code Test or more.

For Code Test situations, an alternative rule of thumb is that the normal approximation is good when both Code Test and Code Test exceed Code Test (some sources use Code Test). This ensures that the distribution is far from being pushed against Code Test or Code Test and has enough room in both tails.

In our simulation, Code Test works beautifully for the symmetric Code Test case. If we used a Code Test instead, which is highly skewed, we would need a much larger Code Test to see the bell shape emerge.

The Continuity Correction

When the CLT approximates a discrete distribution, such as a binomial count, a small adjustment sharpens the result. A discrete variable puts probability on the integers, while the approximating normal spreads probability continuously, so the event Code Test is matched better by the normal event Code Test: we widen each integer to the half-unit interval around it. To approximate Code Test for an integer-valued Code Test, apply the normal approximation to Code Test; to approximate Code Test, use Code Test. This continuity correction typically cuts the approximation error several-fold for moderate Code Test, and it is worth applying whenever the underlying variable is a count. Problem 7.7 asks you to measure its effect against an exact binomial tail.

Beyond i.i.d.: Extensions of the CLT

The CLT we have stated assumes i.i.d. random variables. Several extensions relax this:

  • Lindeberg-Feller CLT: allows non-identically-distributed independent variables as long as no single term dominates in the variance.
  • Martingale CLT: allows a specific kind of dependence (martingale differences), useful in stochastic processes.
  • Multivariate CLT: extends to random vectors; the limit is a multivariate normal.
  • Functional CLT (Donsker’s theorem): the entire path of a random walk converges to Brownian motion.

These extensions show how central the CLT is: even in complicated settings, sums of many small independent effects tend to look normal in some appropriate sense.

Why This Matters

The Central Limit Theorem is the reason the normal distribution deserves its special status. It is not just one distribution among many. It is the attractor distribution for sums of independent random variables. Wherever independent effects accumulate, the normal distribution appears. This makes it the most important distribution in probability and statistics, and the CLT tells us why.

Problem Set

Problem 7.1. For the example simulation (Code Test), the CLT predicts Code Test is approximately Code Test. Compute the standard deviation of that normal (should be about Code Test) and identify the range Code Test. Approximately what fraction of the Code Test simulated sample means should fall inside this range?

Problem 7.2. Modify the simulation to use Code Test (a highly skewed Bernoulli). With Code Test, is the histogram of sample means still bell-shaped? Increase Code Test to Code Test. At what point does the bell shape become clear? Explain what you observe using the Berry-Esseen intuition.

Problem 7.3 (Uniform source). Replace the Bernoulli source with a Code Test source. Draw Code Test sample means with Code Test. Confirm that the sample means look approximately Code Test. Because Code Test has mean Code Test and variance Code Test, and the mean of Code Test samples has variance Code Test, this is the CLT.

Problem 7.4 (Exponential source). Replace the source with an exponential of rate Code Test (mean Code Test, variance Code Test). Draw Code Test sample means with Code Test, and Code Test. Because the exponential is right-skewed, the bell shape emerges more slowly than with the uniform. Compare the empirical histograms.

Problem 7.5 (Sample size for margin of error). How large a random sample Code Test do you need so that a 95% confidence interval for a Bernoulli proportion has half-width at most Code Test? Use the worst case Code Test. What if the half-width must be Code Test?

Problem 7.6 (CLT vs. Chebyshev). For a Code Test source with Code Test, use Chebyshev’s inequality to bound Code Test. Then use the CLT to compute the same probability under the normal approximation. Compare the two bounds. Which is tighter?

Problem 7.7 (Approximating a binomial tail). Use the CLT (with continuity correction if you know it) to approximate Code Test where Code Test is Code Test. Then compute the exact binomial probability using the example program from Chapter 4. How close are the two answers?

Problem 7.8 (Coding exercise). Add a function that computes the empirical CDF of the sample means. Compare it against the CLT-predicted normal CDF and print the maximum absolute difference. This is a numerical estimate of the Berry-Esseen bound in action. Verify that this maximum difference shrinks as you increase Code Test.

Problem 7.9 (When the CLT fails). The CLT requires finite variance. Recall the Cauchy distribution from Chapter 6. Simulate Code Test sample means of Code Test Cauchy draws. Plot the histogram. Is it bell-shaped, or does it look like the Cauchy itself? Explain your observation.