Skip to main content
© 2026 ePowerAI — free, open courseware. No login required.
CoursesContact
ePOWERAI
CoursesContact
Week 7: Laws of Large Numbers and the CLT
Prob & Stats

Foundations

  1. 01Week 1: Probability Spaces and Events
  2. 02Week 2: Random Variables and Distributions
  3. 03Week 3: Expectation, Variance, and Covariance
  4. 04Week 4: Conditioning and Independence
  5. 05Week 5: Bayes' Rule and Generative Classification
  6. 06Week 6: Multivariate Gaussians

Inference

  1. 07Week 7: Laws of Large Numbers and the CLT
  2. 08Week 8: Point Estimation — Maximum Likelihood
  3. 09Week 9: Bayesian Estimation and MAP
  4. 10Week 10: Bias, Variance, and Uncertainty

ML interface

  1. 11Week 11: Information Theory for ML
  2. 12Week 12: Exponential Families (lite)
  3. 13Week 13: Graphical Models (lite)

Capstone

  1. 14Week 14: Capstone — Probabilistic Language of ML
Week 07· Prob & Stats· Inference9 min read

Week 7: Laws of Large Numbers and the CLT

Learning Outcomes
  • State the LLN: sample mean →\to→ expectation (in probability vocabulary)
  • State the CLT for i.i.d. sums with finite variance
  • Simulate sampling distributions of the mean
  • Avoid CLT misuse for tiny nnn or infinite variance stories
Prerequisites

Required: Weeks 2–3 (random variables, expectation, variance). Week 6 (multivariate Gaussians) is helpful but not required, since the CLT produces a univariate normal.

Importance: The LLN justifies learning from data (empirical averages →\to→ true expectations), and the CLT underlies confidence intervals (Week 10), MLE asymptotics (Week 8), and why squared-error losses couple naturally with Gaussian noise assumptions.

  • Also see: Optimization Week 3: Gradient Descent Theory — how these sample-level guarantees meet training guarantees.

i.i.d. samples#

The most important assumption in classical statistics: independent and identically distributed (i.i.d.). A sequence X1,X2,…,XnX_1, X_2, \ldots, X_nX1​,X2​,…,Xn​ is i.i.d. if:

  • Identically distributed: each XiX_iXi​ has the same CDF/PMF/PDF, so they are draws from the same population.
  • Independent: knowing X1,…,Xi−1X_1, \ldots, X_{i-1}X1​,…,Xi−1​ tells you nothing about XiX_iXi​.

Think of repeatedly rolling the same die, or drawing with replacement from a population. The i.i.d. assumption makes the sample mean a simple, well-behaved statistic.

Why it matters: both the Law of Large Numbers and the Central Limit Theorem require i.i.d. (or at least weak dependence + identical marginals). When data are dependent (time series, spatial data, within-subject repeats), the standard formulas underestimate uncertainty.

Law of large numbers#

The Weak Law of Large Numbers (LLN): as n→∞n \to \inftyn→∞, the sample mean Xˉn=1n∑i=1nXi\bar X_n = \frac{1}{n}\sum_{i=1}^n X_iXˉn​=n1​∑i=1n​Xi​ converges in probability to the true mean μ=E[Xi]\mu = \mathbb{E}[X_i]μ=E[Xi​]:

lim⁡n→∞P(∣Xˉn−μ∣>ε)=0for any ε>0.\lim_{n \to \infty} P(|\bar X_n - \mu| > \varepsilon) = 0 \quad \text{for any } \varepsilon > 0.n→∞lim​P(∣Xˉn​−μ∣>ε)=0for any ε>0.

In plain language: with enough samples, the sample average is almost certainly close to the population mean. The probability of a deviation larger than any fixed ε\varepsilonε shrinks to zero.

Why convergence in probability, not convergence of the sequence? The Xˉn\bar X_nXˉn​ are random: each repetition of the experiment gives a different path. The LLN says that the probability of being far from μ\muμ vanishes; it does not say that a particular realised sequence must converge. (The Strong Law does, but we use the Weak Law here as it is sufficient for our purposes.)

Monte Carlo integration is a direct application: to estimate E[g(X)]\mathbb{E}[g(X)]E[g(X)], sample X1,…,Xn∼pX_1, \ldots, X_n \sim pX1​,…,Xn​∼p and compute 1n∑ig(Xi)\frac{1}{n}\sum_i g(X_i)n1​∑i​g(Xi​). The LLN guarantees this converges to the true expectation. This is how many Bayesian computations and reinforcement learning value estimates work.

Worked example: coin flips. Flip a fair coin nnn times; let Xi=1X_i = 1Xi​=1 for heads, 0 for tails. E[Xi]=0.5\mathbb{E}[X_i] = 0.5E[Xi​]=0.5. The sample proportion of heads converges to 0.5:

  • n=10n = 10n=10: Xˉ\bar XXˉ might be anywhere from 0.2 to 0.8.
  • n=100n = 100n=100: usually within 0.4–0.6.
  • n=10,000n = 10,000n=10,000: almost always within 0.49–0.51.

The LLN tells us that concentration happens, but not how fast. That is the role of the CLT and variance formulas.

Central limit theorem#

as n grows, the sampling distribution of the mean concentrates small n medium n large n LLN: averages converge · CLT: the fluctuations become Gaussian

The law of large numbers says the sample mean converges to the true mean; the central limit theorem says more: the fluctuations around it become Gaussian, with width shrinking like 1/n1/\sqrt{n}1/n​. That is where confidence intervals and MLE asymptotics come from.

The Central Limit Theorem (CLT) is deeper: it describes the shape of the sampling distribution of the mean. For i.i.d. XiX_iXi​ with mean μ\muμ and finite variance σ2\sigma^2σ2:

Xˉn−μσ/n  →d  N(0,1).\frac{\bar X_n - \mu}{\sigma / \sqrt{n}} \;\xrightarrow{d}\; \mathcal{N}(0, 1).σ/n​Xˉn​−μ​d​N(0,1).

"→d\xrightarrow{d}d​" means convergence in distribution: the CDF of the standardised mean approaches the standard normal CDF.

What the CLT says:

  • The sample mean Xˉn\bar X_nXˉn​ is approximately N(μ,σ2/n)\mathcal{N}(\mu, \sigma^2 / n)N(μ,σ2/n).
  • The approximation improves as nnn grows.
  • The original distribution of XiX_iXi​ can be anything (discrete, skewed, bounded, multimodal): as long as the variance is finite, sums become Gaussian.
  • The rate of convergence is roughly O(1/n)O(1/\sqrt{n})O(1/n​) (Berry–Esseen theorem).

CLT in practice: standard error. The standard deviation of Xˉn\bar X_nXˉn​ is σ/n\sigma / \sqrt{n}σ/n​, called the standard error. It shrinks at rate 1/n1 / \sqrt{n}1/n​, so to halve your error, you need four times as many samples.

Worked example: exponential population. Xi∼Exponential(λ=1)X_i \sim \text{Exponential}(\lambda = 1)Xi​∼Exponential(λ=1). Then μ=1\mu = 1μ=1, σ2=1\sigma^2 = 1σ2=1. For n=100n = 100n=100, the standard error is σ/n=1/10=0.1\sigma / \sqrt{n} = 1/10 = 0.1σ/n​=1/10=0.1. So Xˉ100\bar X_{100}Xˉ100​ is approximately N(1,0.12)\mathcal{N}(1, 0.1^2)N(1,0.12). About 95% of sample means will fall in μ±2⋅SE=1±0.2\mu \pm 2 \cdot \text{SE} = 1 \pm 0.2μ±2⋅SE=1±0.2, or [0.8,1.2][0.8, 1.2][0.8,1.2].

Notice that the original exponential data is far from normal: it is skewed right, with a sharp peak at 0. Yet the distribution of the mean of 100 such observations is nearly bell-shaped. That is the CLT's power.

Sampling distribution of the mean#

The sampling distribution of a statistic is the distribution of that statistic over repeated samples of size nnn from the same population.

For the sample mean:

  • Mean of sampling distribution: E[Xˉn]=μ\mathbb{E}[\bar X_n] = \muE[Xˉn​]=μ (unbiased).
  • Variance of sampling distribution: Var(Xˉn)=σ2/n\mathrm{Var}(\bar X_n) = \sigma^2 / nVar(Xˉn​)=σ2/n (shrinks with nnn).
  • Shape: approximately normal for large nnn (CLT), exactly normal for any nnn if the XiX_iXi​ are themselves normal.

Degrees-of-freedom intuition: why σ2/n\sigma^2 / nσ2/n? When we average nnn independent observations, their individual fluctuations partly cancel. The variance of a sum of independent variables is the sum of variances: Var(∑Xi)=nσ2\mathrm{Var}(\sum X_i) = n\sigma^2Var(∑Xi​)=nσ2. Dividing by nnn gives Var(Xˉn)=σ2/n2⋅n=σ2/n\mathrm{Var}(\bar X_n) = \sigma^2 / n^2 \cdot n = \sigma^2 / nVar(Xˉn​)=σ2/n2⋅n=σ2/n.

Limitations#

The CLT is powerful but not magical. It fails or misleads in important cases:

  • Heavy tails (infinite variance): If σ2=∞\sigma^2 = \inftyσ2=∞ (e.g., Cauchy distribution), the CLT does not apply. Sums of Cauchy variables remain Cauchy, not Gaussian, so the sample mean never concentrates.
  • Small nnn with skewed data: For n=5n = 5n=5, the sampling distribution of the mean from an exponential population is still noticeably skewed. The n→∞n \to \inftyn→∞ guarantee does not say what happens at n=5n = 5n=5.
  • Dependence: If XiX_iXi​ are not independent (e.g., stock returns on consecutive days), the standard error σ/n\sigma/\sqrt{n}σ/n​ is wrong (usually an underestimate). Time series methods (autocorrelation, block bootstrap) are needed.
  • Extreme quantiles: The CLT describes the centre of the distribution, not the tails. For a 99.9% VaR calculation, normality of the mean is insufficient, since tail behaviour depends on the original distribution's tail.

The pragmatic rule: for "nice" distributions (finite variance, not pathologically skewed) with n≥30n \ge 30n≥30, the normal approximation is usually adequate for central intervals. For confidence intervals on the mean, the CLT is the workhorse, but always check your data's tail behaviour before trusting extreme quantiles.

Exercise · Fill in the blank

If X_i are i.i.d. with variance σ² = 9, what is the variance of the sample mean of n = 36 observations?


Knowledge check#

Question 1 of 4

Which theorem ensures that the sample mean approaches the population mean as n → ∞?

Law of Large Numbers
Central Limit Theorem
Bayes' rule
Bootstrap theorem

Browser lab#

Show the LLN (running mean vs n) and CLT (histogram of many sample means) for uniform and exponential populations.

python · runs in browser
import numpy as np
import matplotlib.pyplot as plt

rng = np.random.default_rng(42)
pop_size = 5000
n_means = 2000

fig, axes = plt.subplots(2, 3, figsize=(14, 8))

for row, (dist_name, dist_fn, mu_true, sigma_true) in enumerate([
    ("Uniform(2, 6)", lambda sz: rng.uniform(2, 6, size=sz), 4.0, np.sqrt(16/12)),
    ("Exponential(λ=1)", lambda sz: rng.exponential(1, size=sz), 1.0, 1.0),
]):
    # LLN: single long sequence
    samples = dist_fn(pop_size)
    running_mean = np.cumsum(samples) / np.arange(1, pop_size + 1)
    ax = axes[row, 0]
    ax.plot(running_mean, linewidth=0.8)
    ax.axhline(mu_true, color="tab:red", linestyle="--", label=f"μ = {mu_true}")
    ax.set_xscale("log"); ax.set_xlabel("n (log scale)")
    ax.set_ylabel("Running mean")
    ax.set_title(f"LLN — {dist_name}")
    ax.legend()

    # CLT: many sample means for a fixed n
    for col_idx, n in enumerate([5, 30]):
        means = np.array([dist_fn(n).mean() for _ in range(n_means)])
        ax = axes[row, 1 + col_idx]
        ax.hist(means, bins=50, density=True, alpha=0.7)
        x_grid = np.linspace(means.min(), means.max(), 200)
        se = sigma_true / np.sqrt(n)
        normal_approx = (1/(np.sqrt(2*np.pi)*se)) * np.exp(-0.5*((x_grid - mu_true)/se)**2)
        ax.plot(x_grid, normal_approx, "tab:red", linewidth=2, label="CLT approx")
        ax.set_title(f"CLT — n={n}, {dist_name}")
        ax.set_xlabel("Sample mean"); ax.legend()

plt.tight_layout()
plt.show()

print("LLN + CLT demo complete.")
print("Uniform: μ=4.0, σ/√30 ≈ {:.3f}".format(np.sqrt(16/12)/np.sqrt(30)))
print("Exponential: μ=1.0, σ/√30 ≈ {:.3f}".format(1.0/np.sqrt(30)))

print("Notice: the standardised sample means converge to σ/√30 ≈ 0.211 (uniform) and 0.183 (exponential), whatever the shape of the underlying draws.")

Key takeaways#

  • The i.i.d. assumption (identical distribution and independence) is what makes the sample mean well-behaved. Dependence breaks the standard error formulas.
  • The weak law of large numbers says the sample mean converges in probability to the true mean. This is what licenses Monte Carlo estimation of expectations.
  • The central limit theorem says the standardised sample mean converges in distribution to a standard normal, whatever the shape of the population, as long as the variance is finite.
  • The standard error is σ/n\sigma / \sqrt{n}σ/n​, so halving the error requires four times the data.
  • The CLT fails for infinite-variance distributions, is unreliable at small nnn with skewed data, and says nothing about the tails.
  • For central intervals with nnn around 30 or more and finite variance, the normal approximation is usually adequate; check the tails before trusting extreme quantiles.

Further reading#

  • Joseph K. Blitzstein & Jessica Hwang, Introduction to Probability (2nd ed., CRC Press, 2019): the law of large numbers and central limit theorem with simulation-based intuition.
  • Larry Wasserman, All of Statistics (Springer, 2004): Chapter 5 covers convergence in probability and distribution.
  • George Casella & Roger L. Berger, Statistical Inference (2nd ed., Duxbury, 2002): the limit-theorem chapter with full proofs.

Reading is free. PDF and ePub unlock with the newsletter. Join once and every lesson opens in this browser.

← Previous
Week 6: Multivariate Gaussians
Next →
Week 8: Point Estimation — Maximum Likelihood
On this page
  • i.i.d. samples
  • Law of large numbers
  • Central limit theorem
  • Sampling distribution of the mean
  • Limitations
  • Knowledge check
  • Browser lab
  • Key takeaways
  • Further reading