The central limit theorem says that if you take many random samples from almost any data and compute the average of each sample, those averages form a bell-shaped (normal) curve. This happens even when the original data is skewed, and it gets more accurate as each sample gets larger. It is the reason many statistical tools can work with averages without knowing the shape of the raw data.
What does the central limit theorem actually say?
Three things, in plain words:
1. Take a sample of n values and compute its mean. Repeat this many times.
2. The means form a bell curve centered on the true mean of the data.
3. The spread of that curve (the standard error) is the standard deviation of the data divided by the square root of n.
The raw data does not need to look like a bell. It only needs to have a finite spread and independent values. A bigger n gives a narrower and more symmetric curve.
Why does it matter?
Real data is often messy. Order amounts, waiting times and incomes pile up on the low side with a long tail on the high side. If you could only use statistics on bell-shaped data, you could not use them on most real data.
Because averages behave like a bell curve, you can estimate how far a sample mean is likely to be from the true mean, build confidence intervals and run tests. You can read more in [normal distribution and the 68-95-99.7 rule](/blog/normal-distribution) and [confidence interval explained](/blog/confidence-interval-explained).
How can you see it in Python?
Use the order amounts from Bazaar, a fictional online store. The data is strongly skewed: most orders are small and a few are very large.
import numpy as np import pandas as pd url = "orders.csv" amount = pd.read_csv(url)["amount"] print(len(amount), round(amount.mean(), 2), round(amount.median(), 2), round(amount.std(), 2))
885 75.53 44.95 101.22
There are 885 orders. The mean is $75.53, the median is $44.95 and the standard deviation is $101.22. A mean far above the median is a sign of right skew. Now draw 5,000 samples of each size and look at the means:
rng = np.random.default_rng(3) for n in [1, 5, 30, 100]: means = pd.Series([rng.choice(amount.values, n).mean() for _ in range(5000)]) print(n, round(means.mean(), 2), round(means.std(), 2), round(amount.std() / np.sqrt(n), 2), round(means.skew(), 2))
1 74.78 103.44 101.22 4.26 5 74.21 44.35 45.27 1.92 30 75.2 18.37 18.48 0.77 100 75.32 10.2 10.12 0.36
The columns are sample size, the average of the sample means, the spread of the sample means, the spread the theorem predicts (std / sqrt(n)), and the skewness (0 means symmetric).
What do the results show?
- The center stays the same. The average of the sample means stays close to $75.53 for every
n. - The spread matches the formula. At
n = 30, the simulated spread is 18.37 and the formula gives 18.48. - The skew fades. With one order per sample (
n = 1), the skew is 4.26, the shape of the raw data. With 100 orders per sample it is 0.36, close to a symmetric bell.
Notice the spread: going from 1 to 100 orders per sample cuts it from about $103 to about $10, roughly ten times smaller. Because the formula divides by the square root of n, you need four times more data to cut the spread in half.
How large must the sample be?
A common rule of thumb is n = 30, and in this data the skew at 30 (0.77) is already much lower than at 5 (1.92). But the rule is only a guide. The more skewed the data, the larger the sample you need. For very heavy tails, 30 can be too small.
What are common mistakes?
- Thinking the data becomes normal. Only the distribution of the sample means becomes normal. Your raw data stays skewed.
- Mixing up the two spreads. The standard deviation describes individual values. The standard error describes how much the sample mean moves between samples.
- Using it on biased samples. The theorem assumes random, independent samples. A biased sample gives a bell curve around the wrong center.
What to read next
- Practice this idea in the lesson [Normal model and the central limit theorem](/learn/statistics-data-analysis/normal-model-clt), or browse the [Statistics and Data Analysis course](/courses/statistics-data-analysis).
- Learn how a sample mean turns into a range in [confidence interval explained](/blog/confidence-interval-explained).
- Review the spread measure used above in [standard deviation explained](/blog/standard-deviation-explained).
- #statistics
- #central limit theorem
- #sampling
- #python