The central limit theorem
Last updated
Lesson 8.3 found that sample means pile up in a neat, narrow hump around the truth. That isn't luck: it's the central limit theorem, one of the most useful results in statistics. It says that means of samples are close to normal, whatever shape the data has, and it tells you exactly how wide the hump is. In this lesson you'll watch it happen, compute a standard error from one sample, and see the kind of data where the theorem fails.
By the end of this lesson you can
- Say what the central limit theorem says, and when it applies
- Compute the standard error of a mean from one sample
- Explain how sample size changes the standard error
- Recognise heavy-tailed data, where means don't settle
Means of many draws
Receipts are skewed: lots of small ones, a long tail of big ones. What do means of receipts look like? The cell takes 5,000 samples of 1, 2, 5 and 30 receipts (with replacement) and draws a histogram of the means in each case. Run it.
- Means of 1 are just receipts: skewed, skew 1.29.
- Means of 2 are already less skewed (0.87): a big receipt is often paired with a small one.
- Means of 5: skew 0.54.
- Means of 30: skew 0.16, and the bars follow the pink normal curve closely.
That's the central limit theorem (CLT). If you take samples of size from almost any population with mean and standard deviation , the sample mean is approximately normal, and more so as grows:
is the normal distribution with mean and variance , so standard deviation . It doesn't matter much what shape the data has. Try other shapes:
Means of 1: skew 1.32, standard deviation ₱72.37. The pink curve is the normal the theorem predicts, with standard deviation σ/√n = ₱71.78. With n = 1 a “mean” is just one value, so the bars are the starting shape.
With two humps or a flat uniform shape, means of 5 already look normal; the skewed receipts need more, about 30. The heavy tail is different, and step 4 is about it.
The standard error
The standard deviation of the sample mean has its own name: the standard error (SE). It says how far a sample mean typically is from the true mean. The CLT says it's . You don't know , the population's standard deviation, but your sample's standard deviation is an estimate of it, so from one sample:
Run the cells: one sample of 40 receipts.
The sample's mean is ₱102.68 and its standard deviation ₱74.49, so its standard error is ₱11.78. stats.sem (standard error of the mean) gives the same. The second cell checks it the long way, with 2,000 samples of 40: their means have a standard deviation of ₱11.06. One sample predicted, from its own spread, how much samples like it wobble.
Don't mix the two up: the standard deviation describes the data (how much receipts vary); the standard error describes an estimate (how much a mean of 40 receipts would vary from sample to sample).
Sample size
Because is under a square root, the standard error shrinks slowly. The table in the last cell shows it: ₱22.71 for 10 receipts, ₱11.35 for 40, ₱5.68 for 160, ₱2.84 for 640. Every time you want to halve the error, you need four times the data. Step through it:
This is why surveys of a few hundred people are common and surveys of a few hundred thousand are rare: going from 1,000 to 100,000 people only makes the error ten times smaller, for a hundred times the cost. And it's why a survey of 1,000 can describe 100 million people: the error depends on the size of the sample, not of the population (as long as the sample is random, as 8.3 warned).
When it fails: heavy tails
The CLT needs to be a finite number. Some data has tails so heavy that it isn't: a few values are so enormous that the variance never settles. Likes on social media posts, the sizes of cities, people's wealth and the damage done by storms are like that. Run the cells: 100,000 made-up posts, where the true mean is 30 likes.
After 100 posts the mean is 35.1; after 1,000 it's 21.9; after 10,000, 22.8; after 100,000, 29.7. The chart shows the "mean so far" crawling along, then jumping up whenever a viral post arrives (the biggest has 280,879 likes). It's nowhere near settled even after 100,000 posts. The median, meanwhile, is 8.8 to 9.0 likes from the first hundred posts on.
For data like this, the mean of a sample tells you little and its standard error is meaningless. Describe it with the median and percentiles (8.1), look at the biggest values on their own, or analyse the logarithm. The check is the same as always: look at the histogram first, and at the largest values. If one value is thousands of times the median, be suspicious of any mean.
Wrong way: ten receipts
The owners want to know what the week's takings will be, but only typed in ten receipts so far. Someone multiplies their mean by the week's 1,203 receipts. Run the cells.
The ten receipts average ₱125.00, so the projection is ₱150,375. The real week took in ₱131,396: the projection is ₱18,979 too high, about 14%. Another ten receipts would have said ₱117.80.
Nothing was miscalculated. The problem is treating ₱125.00 as if it were exact. Its standard error is ₱26.05, so the true mean could easily be anywhere from about ₱73 to ₱177 (two standard errors either side), which makes the projection anything from about ₱88,000 to ₱213,000. Reported as "₱150,375", it sounded certain to the peso.
The check: whenever you report a mean from a sample, work out its standard error, and say how uncertain the number is ("about ₱125, give or take ₱50"). If the uncertainty is too big for the decision, get a bigger sample. Lesson 8.5 turns this into a confidence interval.
Check what you learned
Sources
Every example on this page was run with Python 3.14, and its output and error messages are copied from it. These pages cover the same ground in more depth.
- Diez, Çetinkaya-Rundel and Barr, OpenIntro Statistics, 4th ed., chapters 5 and 7: the central limit theorem and the standard error, with the conditions for using them
- SciPy: scipy.stats.sem: the standard error of the mean
- NIST/SEMATECH e-Handbook of Statistical Methods: Cauchy Distribution: a distribution so heavy-tailed that its sample means never settle
- Newman, Power laws, Pareto distributions and Zipf’s law, Contemporary Physics 46(5), 2005: heavy-tailed data in the real world, and why its mean is unstable