Skip to main content
© 2026 ePowerAI. All rights reserved.
CoursesContact
eAI
CoursesContact
Week 7: Laws of Large Numbers and the CLT
Prob & Stats
01Week 1: Probability Spaces and Events
02Week 2: Random Variables and Distributions
03Week 3: Expectation, Variance, and Covariance
04Week 4: Conditioning and Independence
05Week 5: Bayes' Rule and Generative Classification
06Week 6: Multivariate Gaussians
07Week 7: Laws of Large Numbers and the CLT
08Week 8: Point Estimation — Maximum Likelihood
09Week 9: Bayesian Estimation and MAP
10Week 10: Bias, Variance, and Uncertainty
11Week 11: Information Theory for ML
12Week 12: Exponential Families (lite)
13Week 13: Graphical Models (lite)
14Week 14: Capstone — Probabilistic Language of ML
Week 07· Prob & Stats· Inference20 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 — 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.

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 — 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#

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​ — 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 — 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 — 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)))
← 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