Law of large numbers & central limit theorem

Step 16 of 18 in Foundations · Theorem · Medium

Averages of many samples converge to the true mean (LLN), and their distribution becomes Gaussian whatever the original shape (CLT). This is why sample statistics and A/B tests work.

The lesson

Two theorems about averages. The law of large numbers: the mean of n samples closes in on the true mean as n grows. The central limit theorem says how: for large n the sample mean is distributed almost exactly as Normal(μ, σ²/n), whatever the shape of the distribution you sampled from.

Worked example: means of samples from an exponential with mean 1 and σ = 1
  1. n = 1: the raw, heavily skewed exponential.
  2. n = 30: the means cluster round 1 with spread 1/√30 ≈ 0.18, and the histogram is nearly a bell.
  3. n = 100: tighter again, spread 0.1.

The spread of the sample mean, σ/√n, is called the standard error. Every error bar on a test accuracy and every A/B test leans on it.

Common mistake. The theorem is about the average, not the data. A million samples from an exponential still look exponential. And it needs finite variance: very heavy-tailed data can break it.

Check yourself

  1. σ = 2 and n = 100. What is the standard error of the mean?

    Show the answer

    0.2. σ / √n = 2 / 10 = 0.2.

  2. You draw 1,000,000 samples from an exponential distribution. Their histogram looks:

    • normal
    • uniform
    • exponential
    Show the answer

    exponential. More samples only draw the true shape more sharply. It is the means of groups of samples that turn normal.

  3. To halve the standard error, by what factor must n grow?

    Show the answer

    4. Standard error is σ/√n. Halving it needs √n to double, so n × 4.

Build it

  1. Watch the CLT happen

    Take means of n samples from an exponential distribution for n = 1, 5, 30, 100; plot the histogram of 10,000 means for each.

    Done when: Histograms become bell-shaped and narrower like 1/√n.

    Runs in your browser: write the code on the map and the tests mark it.

Resources

Earn this star

On the map, your answers are marked and you log what you built. Finish the step and its star lights.

Open this step on the map