29 — Statistical Foundations

Central Limit Theorem & Sampling#

Statistics✓ Mathematical
◆ The PatternWhy averages become normal — the theorem underneath every CI and t-test

Take any population — skewed, lumpy, weird. Draw samples of size n and compute each sample's mean. The Central Limit Theorem says the distribution of those means approaches a normal distribution as n grows, regardless of the population's shape. That single fact is why confidence intervals, t-tests, and A/B testing work at all.

x̄  →  N(μ, σ²/n)
Sampling distribution of the mean: centred on the true mean μ, with variance shrinking as 1/n.
SE = σ / √n
Standard error = the standard deviation of the sample mean. Quadruple the sample to halve the error.
// Interactive — skew the population, grow n, watch the sample means turn normal
Population skew0.70
Sample size n5
SE ∝ 1/√n
# Python — watch the CLT happen
import numpy as np
import matplotlib.pyplot as plt

# A very non-normal population (exponential)
population = np.random.exponential(scale=1.0, size=1_000_000)

for n in [1, 5, 30]:
    means = [np.mean(np.random.choice(population, n))
             for _ in range(10_000)]
    plt.hist(means, bins=60, alpha=0.5, label=f"n={n}")

plt.legend(); plt.title("Sampling distribution of the mean")
plt.show()

# Standard error shrinks as 1/sqrt(n)
print(population.std() / np.sqrt(30))
ConceptWhat it saysPractical use
Law of Large Numbersx̄ → μ as n growsMore data → estimates converge
Central Limit Theoremx̄ becomes normally distributedJustifies CIs, t-tests, z-tests
Standard errorSpread of x̄ is σ/√nSizing experiments, error bars
Rule of thumb: n ≥ 30 usually suffices for the normal approximation — but the more skewed the population, the more n you need. Very heavy-tailed data (rare in nature, common in finance) converges slowly or, with infinite variance, not at all.
Pattern bridge: The CLT also assumes independent draws. Market returns are autocorrelated and fat-tailed — see distribution shape and Monte Carlo simulation for why financial error bars deserve extra suspicion.
When to use this
Use when: Reasoning about any average, proportion, or error bar — experiment metrics, survey estimates, batch statistics in monitoring.
Skip when: Data is strongly dependent (time series), heavy-tailed, or you care about extremes rather than means — the CLT says nothing about the tails of the original distribution.
Quick start — copy to notebook
pip install numpy matplotlib
# ────────────────────────────────────────
import numpy as np
import matplotlib.pyplot as plt

population = np.random.exponential(1.0, 1_000_000)

fig, axes = plt.subplots(1, 3, figsize=(12, 3), sharex=True)
for ax, n in zip(axes, [1, 5, 30]):
    idx = np.random.randint(0, len(population), (10_000, n))
    ax.hist(population[idx].mean(axis=1), bins=60)
    ax.set_title(f"sample means, n = {n}")
plt.tight_layout(); plt.show()
← Previous
Choosing the Right Statistical Test
Open in the full reader, with the topic sidebar →