We rarely measure everyone. We take a sample and use its mean to estimate the population mean.
The central limit theorem
Take many samples of size n and compute each sample's mean. The central limit theorem says:
- the sample means cluster around the true mean;
- their spread (the standard error) is σ ÷ √n, shrinking as samples grow;
- their distribution is close to normal, even if the data themselves are not.
The example draws from a lopsided population (mostly small values, a few large ones) and shows the means landing near the true mean.
import random
random.seed(1)
population = [1, 1, 1, 2, 2, 3, 10]
true_mean = sum(population) / len(population)
means = []
for _ in range(20):
sample = random.choices(population, k=5)
means.append(sum(sample) / 5)
print("true mean", round(true_mean, 2))
print("mean of 20 sample means", round(sum(means) / 20, 2))
print("smallest and largest sample mean", min(means), max(means))random.seed(1) makes the "random" draws the same on every run, so the visualizer and your own run agree.
Why it matters
This is why polls of about 1,000 people can describe a whole country, and why the confidence intervals and tests in the next lessons use the normal curve.
Common mistakes
- Thinking a bigger population needs a bigger sample. The standard error depends on the sample size n, not on the population size.
Quick check
My notes
Write down what you want to remember from this lesson. Notes are saved on this device as you type, and appear on your dashboard.