Sampling distribution simulator
This central limit theorem simulator draws thousands of random samples from a population you choose and plots the mean of each one. The histogram of those means is the sampling distribution of the mean. Compare it with the normal curve the theorem predicts, and its spread with the standard error σ/√n. Everything runs in your browser.
Result
| Sample means | Simulation | Theory |
|---|---|---|
| Mean | – | – |
| Standard deviation (standard error σ/√n) | – | – |
| Skewness (0 for a symmetric shape) | – | – |
What a sampling distribution is
Take a sample of n values from a population and compute its mean. A second sample gives a slightly different mean, a third another. The sampling distribution of the mean is the distribution of all those possible sample means; the histogram above builds it one sample at a time. Its centre and spread tell you how far the mean of the one sample you actually have is likely to be from the population mean μ. Our article on the sampling distribution works through the theory with this simulator, and the guide on how to interpret confidence intervals uses it to show what the 95% means.
The central limit theorem
The central limit theorem says that if you repeatedly draw samples of a given size and calculate their means, "those means tend to follow a normal distribution", and more closely so as the sample size grows, whatever the shape of the population (Illowsky and Dean, 2023). The theorem needs the population's standard deviation to be finite.
It is a statement about the means, not about the data. A large sample from a skewed population is still skewed; only the means of many such samples pile up into a bell. Nor is there one sample size that is large enough for every population. The skewness of the mean is γ/√n, where γ is the skewness of the population (Hesterberg, 2014), so it fades only slowly with n. For a symmetric population such as the uniform, γ = 0; for the exponential, γ = 2, and the means' skewness is still 0.365 at n = 30. Hesterberg calls the usual rule of using t methods when n ≥ 30 and the data are not too skewed "imprecise and inadequate".
The standard error
The standard deviation of the sampling distribution is called the standard error. For the mean of n independent values from a population with standard deviation σ:
For a sample proportion p̂, here the share of a sample's values above a threshold, where p is that share in the population (Holmes, Illowsky and Dean, 2023):
Both shrink with √n, so a sample four times as large halves the standard error. Unlike the normal shape, these formulas do not depend on n being large. The tool reports the standard deviation of your simulated values next to them, and the skewness next to γ/√n (for a proportion, (1 − 2p)/√(np(1 − p))). The standard error is what a confidence interval is built from: our confidence interval calculator turns it into a margin of error, and the normal CDF calculator gives areas under the normal curve the theorem predicts.
Worked example
With the right-skewed population (exponential with μ = σ = 1 and skewness 2), 2,000 samples and seed 2026, run once with n = 5 and once with n = 30. These numbers are computed by the tool's own code when the page is built:
| n | SD of the means | σ/√n | Skewness of the means | γ/√n |
|---|---|---|---|---|
| 5 | 0.4544 | 0.4472 | 0.811 | 0.894 |
| 30 | 0.1857 | 0.1826 | 0.414 | 0.365 |
In both runs the spread of the means matches σ/√n closely (0.4544 against 0.4472, then 0.1857 against 0.1826). The shape converges more slowly: at n = 30 the means still have a skewness of 0.414, so the normal curve fits less well in the right tail than in the centre.
What to try
- n = 1: the histogram of "means" is just the population itself.
- Bimodal with n = 2: three humps, because two values can come from the left hump, the right one, or one of each.
- Right-skewed with n = 5, 30 and 200: watch the skewness row approach 0.
- A proportion with a threshold far in a tail and a small n: the histogram is lumpy and lopsided.
Limits
The tool samples with replacement, so draws are independent. Sampling without replacement from a finite population makes the standard error smaller; Holmes, Illowsky and Dean (2023) say a correction is appropriate when more than 5% of the population is sampled. Simulated standard deviations and skewness are estimates that vary from seed to seed; more samples make them more precise. The orange curve uses the theoretical μ and standard error; it is not fitted to the bars.
Sources
- Illowsky, B. and Dean, S. (2023). Introductory Statistics 2e, section 7.1: The Central Limit Theorem for Sample Means. OpenStax.
- Holmes, A., Illowsky, B. and Dean, S. (2023). Introductory Business Statistics 2e, section 7.3 and section 7.4. OpenStax.
- Efron, B. and Tibshirani, R. J. (1993). An Introduction to the Bootstrap, Table 2.1 (mouse survival data). Chapman & Hall.
- Hesterberg, T. (2014). What Teachers Should Know about the Bootstrap: Resampling in the Undergraduate Statistics Curriculum (longer preprint, sections 4.5 and 5.6.1). arXiv:1411.5279.