Sampling distribution simulator

A population, one sample of n from it, and the means of 4,000 samples. Change n and compare.

Drag or tap across the top bars to reshape the population, or pick a preset. Panel 2 is one sample of n values; panel 3 is the means of 4,000 such samples. Each panel has its own count axis.

Reading the three panels

The simulator draws the three distributions that statistics keeps apart, on one horizontal scale[1]:

  1. The population (orange): every value you could draw. Each bar shows the percentage of the population in it. In real life you never see this panel.
  2. One sample (black dots): n values drawn at random from the population, counted per bar. The dashed outline is what the population predicts for n values. Raise n and the sample looks more like the population, long tail and all. A sample of 100 from the skewed population is still skewed.
  3. The means of many samples (blue): the mean of each of 4,000 samples of size n, counted per bar. This is the sampling distribution of the mean. Raise n and it narrows like σ/√n and loses the population’s shape.

The 4,000 repetitions only make panel 3 smooth enough to read. It is n, the size of each sample, that narrows it. The small black triangle marks where the one sample from panel 2 landed among the 4,000 means; “Another sample” steps through them.

The numbers under the panels

For any population with a finite standard deviation σ, the sample mean has mean μ and standard deviation σ/√n, exactly[2]. The readout compares that prediction with the simulated means. It also compares their skewness with the exact value γ1/√n, which shows how fast the shape becomes normal: the skewed preset, with γ1 = 1.77, needs n = 79 before the means’ skewness drops to 0.2[3]. established

At n = 1 each “mean” is a single draw, so the dashed curve over panel 3 is the population’s own shape, not a normal curve. From n = 2 it is the normal curve with standard deviation σ/√n that the central limit theorem says the means approach as n grows; its label says “predicted: normal” only once the means’ exact skewness and excess kurtosis are both below 0.2.

What the simulator assumes

  • Each sample is drawn independently and with replacement (equivalently, from a very large population). Correlated or clustered data make the means vary more than σ/√n.
  • The population is a histogram of 40 bars on 0–100 with values spread evenly within each bar; its mean, standard deviation and skewness are computed exactly from those bars.
  • The draws are seeded, so a shared link reproduces the same samples. “Redraw all 4,000” changes the seed.

Sources

  1. Freedman, D., Pisani, R. & Purves, R. (2007). Statistics, 4th edition. W. W. Norton. ISBN 978-0-393-92972-0. textbook Ch. 4 (the standard deviation), ch. 5 (the normal approximation), ch. 16–18 (chance variability and the CLT), ch. 21 (accuracy of percentages).
  2. Rice, J. A. (2007). Mathematical Statistics and Data Analysis, 3rd edition. Duxbury (Thomson Brooks/Cole). ISBN 978-0-534-39942-9. textbook Ch. 2–4 (distributions, moments), §5.3 (central limit theorem), ch. 7 (survey sampling, the n − 1 divisor), ch. 9 (testing).
  3. Hesterberg, T. C. (2015). What teachers should know about the bootstrap: resampling in the undergraduate statistics curriculum. The American Statistician 69(4), 371–386. doi:10.1080/00031305.2015.1089789. review