Math for Causal Inference

Day 7. The Law of Large Numbers & Central Limit Theorem

Why sample means settle down, and why their errors are approximately normal.

Video coming soon
Learning outcomes
  • ●Compute the mean, variance and standard error of a sample mean.
  • ●Prove Markov's and Chebyshev's inequalities and the weak law of large numbers.
  • ●Apply the central limit theorem to sample means, proportions and totals.
  • ●Explain how clustering and fat tails change these results.
2-HOUR SESSION PLAN
Theory 25′Warm-up (1–5) 20′Proofs (6–10) 35′Applied (11–15) 25′Python & Lab 15′
Colab notebook (.ipynb) Jump to the simulator

Theory

The sample mean

Let X1,…,XnX_1, \dots, X_n be independent and identically distributed (iid) with mean μ\mu and variance σ2\sigma^2. The sample mean Xˉn=1n∑iXi\bar X_n = \frac1n\sum_i X_i has

E[Xˉn]=μ,Var⁡(Xˉn)=σ2n,SE⁡(Xˉn)=σn.E[\bar X_n] = \mu, \qquad \operatorname{Var}(\bar X_n) = \frac{\sigma^2}{n}, \qquad \operatorname{SE}(\bar X_n) = \frac{\sigma}{\sqrt n}.

The standard error shrinks like 1/n1/\sqrt n: to halve it, you need four times the data.

Two inequalities

  • Markov: if X≥0X \ge 0, then P(X≥a)≤E[X]/aP(X \ge a) \le E[X]/a for a>0a > 0.
  • Chebyshev: P(∣X−μ∣≥k)≤σ2/k2P(|X - \mu| \ge k) \le \sigma^2/k^2.

Law of large numbers (LLN)

For every ε>0\varepsilon > 0, P(∣Xˉn−μ∣>ε)→0P(|\bar X_n - \mu| > \varepsilon) \to 0 as n→∞n \to \infty. We write Xˉn→pμ\bar X_n \xrightarrow{p} \mu ("converges in probability"). This is why a large experiment's group means are close to the population means.

Central limit theorem (CLT)

Whatever the shape of the distribution of XX (as long as σ2\sigma^2 is finite),

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

For moderate nn, Xˉn≈N(μ,σ2/n)\bar X_n \approx N(\mu, \sigma^2/n). Almost every confidence interval and p-value in applied work rests on this approximation, including those for regression coefficients, which are weighted averages.

When things go wrong

  • Dependence. With mm units per cluster and intra-cluster correlation ρ\rho, the variance of the mean is inflated by the design effect 1+(m−1)ρ1 + (m - 1)\rho.
  • Infinite variance. For very fat-tailed data (e.g. Cauchy), neither the LLN nor the CLT applies.

Part 1 · Warm-up

Exercise 1 · Standard error

Test scores have σ=20\sigma = 20. What is the standard error of a mean from n=100n = 100 students?

Show solution

SE⁡=20/100=2\operatorname{SE} = 20/\sqrt{100} = 2.

Exercise 2 · Diminishing returns

How many students are needed to cut the standard error to 1?

Show solution

20/n=1⇒n=40020/\sqrt n = 1 \Rightarrow n = 400: four times as many for half the error.

Exercise 3 · A probability for the mean

XX has μ=50\mu = 50 and σ=10\sigma = 10. For n=25n = 25, approximate P(Xˉ>53)P(\bar X > 53).

Show solution

SE⁡=10/5=2\operatorname{SE} = 10/5 = 2, z=(53−50)/2=1.5z = (53 - 50)/2 = 1.5, so P≈1−Φ(1.5)≈0.067P \approx 1 - \Phi(1.5) \approx 0.067.

Exercise 4 · A proportion

The true employment rate is 0.3. For a sample of 400, find the standard error of the sample proportion and an interval containing it with about 95% probability.

Show solution

Step 1. A proportion is the mean of 0/1 variables with σ2=p(1−p)=0.3×0.7=0.21\sigma^2 = p(1 - p) = 0.3 \times 0.7 = 0.21.

Step 2. Standard error: 0.21/400=0.000525≈0.0229\sqrt{0.21/400} = \sqrt{0.000525} \approx 0.0229.

Step 3. By the CLT, about 95% of samples fall within 1.96×0.0229≈0.0451.96 \times 0.0229 \approx 0.045 of 0.3.

Answer: SE ≈ 0.023; the sample employment rate lands in [0.255,  0.345][0.255,\; 0.345] about 95% of the time.

Exercise 5 · A total

An insurer has 100 independent claims with mean $500 and sd $300. Approximate the probability that total claims exceed $55,000.

Show solution

Step 1. Total S=∑i=1100XiS = \sum_{i=1}^{100}X_i has mean 100×500=50,000100 \times 500 = 50{,}000.

Step 2. Independent claims, so variances add: Var⁡(S)=100×3002\operatorname{Var}(S) = 100 \times 300^2 and sd⁡(S)=300100=3,000\operatorname{sd}(S) = 300\sqrt{100} = 3{,}000.

Step 3. By the CLT, S≈N(50,000,  3,0002)S \approx N(50{,}000,\; 3{,}000^2). Standardise: z=(55,000−50,000)/3,000≈1.67z = (55{,}000 - 50{,}000)/3{,}000 \approx 1.67.

Step 4. P(S>55,000)≈1−Φ(1.67)≈0.048P(S > 55{,}000) \approx 1 - \Phi(1.67) \approx 0.048.

Answer: about a 5% chance that total claims exceed $55,000.

Part 2 · Proofs

Exercise 6 · Unbiasedness of the sample mean

Prove E[Xˉn]=μE[\bar X_n] = \mu.

Show solution

By linearity, E[Xˉn]=1n∑iE[Xi]=1n(nμ)=μE[\bar X_n] = \frac1n\sum_i E[X_i] = \frac1n(n\mu) = \mu. (Identical distribution is needed; independence is not.)

Exercise 7 · Variance of the sample mean

Prove Var⁡(Xˉn)=σ2/n\operatorname{Var}(\bar X_n) = \sigma^2/n for iid data.

Show solution Var⁡(Xˉn)=1n2Var⁡(∑iXi)=1n2(∑iVar⁡(Xi)+∑i≠jCov⁡(Xi,Xj))=1n2 nσ2=σ2n,\operatorname{Var}(\bar X_n) = \frac{1}{n^2}\operatorname{Var}\Big(\sum_i X_i\Big) = \frac{1}{n^2}\Big(\sum_i \operatorname{Var}(X_i) + \sum_{i \ne j}\operatorname{Cov}(X_i, X_j)\Big) = \frac{1}{n^2}\,n\sigma^2 = \frac{\sigma^2}{n},

because independence makes every covariance zero. Exercise 13 shows what happens when it does not.

Exercise 8 · Markov's inequality

Prove P(X≥a)≤E[X]/aP(X \ge a) \le E[X]/a for X≥0X \ge 0 and a>0a > 0.

Show solution

Step 1. Since X≥0X \ge 0, X≥a 1{X≥a}X \ge a\,\mathbf{1}\{X \ge a\} always holds.

Step 2. Take expectations: E[X]≥a P(X≥a)E[X] \ge a\,P(X \ge a).

Step 3. Divide by aa.

Exercise 9 · Chebyshev's inequality

Derive Chebyshev's inequality from Markov's.

Show solution

Apply Markov to the non-negative variable (X−μ)2(X - \mu)^2 with a=k2a = k^2:

P(∣X−μ∣≥k)=P((X−μ)2≥k2)≤E[(X−μ)2]k2=σ2k2.P(|X - \mu| \ge k) = P\big((X - \mu)^2 \ge k^2\big) \le \frac{E[(X - \mu)^2]}{k^2} = \frac{\sigma^2}{k^2}.

Exercise 10 · The weak law of large numbers

Prove Xˉn→pμ\bar X_n \xrightarrow{p} \mu when σ2<∞\sigma^2 < \infty.

Show solution

Apply Chebyshev to Xˉn\bar X_n, whose variance is σ2/n\sigma^2/n:

P(∣Xˉn−μ∣≥ε)≤σ2nε2→0as n→∞.P(|\bar X_n - \mu| \ge \varepsilon) \le \frac{\sigma^2}{n\varepsilon^2} \to 0 \quad\text{as } n \to \infty.

Part 3 · Applied

Exercise 11 · Budgeting an RCT

An outcome has σ=30\sigma = 30 in both arms. (a) With 225 per arm, what is the standard error of the difference in means? (b) How many per arm are needed for a standard error of 2?

Show solution

(a) SE with 225 per arm

Step 1. Each arm mean has variance σ2/n=900/225=4\sigma^2/n = 900/225 = 4.

Step 2. The arms are independent, so the variance of the difference is 4+4=84 + 4 = 8 and SE⁡=8≈2.83\operatorname{SE} = \sqrt 8 \approx 2.83.

(b) Sample size for SE = 2

Step 3. Solve 2×900/n=2\sqrt{2 \times 900/n} = 2: square both sides, 1800/n=41800/n = 4, so n=450n = 450 per arm.

Answer: SE ≈ 2.83 with 225 per arm; 450 per arm are needed for SE = 2 (twice the sample for a 29% smaller SE).

Exercise 12 · How sure is a survey mean?

A statistics office estimates mean household income from a random sample of nn households. Bound the probability that the sample mean misses the true mean by at least two standard errors, P(∣Xˉn−μ∣≥2σ/n)P(|\bar X_n - \mu| \ge 2\sigma/\sqrt n), using Chebyshev's inequality, and compare with the CLT approximation. Why might the office prefer the Chebyshev figure for very skewed incomes in a small sample?

Show solution

Step 1. Chebyshev with Var⁡(Xˉn)=σ2/n\operatorname{Var}(\bar X_n) = \sigma^2/n and k=2σ/nk = 2\sigma/\sqrt n:

P(∣Xˉn−μ∣≥k)≤σ2/n4σ2/n=0.25.P(|\bar X_n - \mu| \ge k) \le \frac{\sigma^2/n}{4\sigma^2/n} = 0.25.

Step 2. CLT: (Xˉn−μ)/(σ/n)≈N(0,1)(\bar X_n - \mu)/(\sigma/\sqrt n) \approx N(0, 1), so the probability is about 2(1−Φ(2))≈0.0462(1 - \Phi(2)) \approx 0.046.

Answer: at most 25% (Chebyshev) versus about 4.6% (CLT). Chebyshev holds for any distribution and any nn, so it is a safe worst case when incomes are very skewed and the sample small; the CLT figure is sharper but only an approximation.

Exercise 13 · Clustered samples

A school survey samples 100 schools with 20 pupils each. The intra-class correlation is 0.05. Find the design effect and the effective sample size.

Show solution

Step 1. Design effect: DEFF=1+(m−1)ρ=1+19×0.05=1.95\text{DEFF} = 1 + (m - 1)\rho = 1 + 19 \times 0.05 = 1.95.

Step 2. Effective sample size: 2,000/1.95≈1,0262{,}000/1.95 \approx 1{,}026 independent pupils.

Step 3. Standard errors that ignore clustering are too small by 1.95≈1.40\sqrt{1.95} \approx 1.40.

Answer: DEFF = 1.95; the 2,000 pupils carry the information of about 1,026 independent ones.

Exercise 14 · When the LLN fails: very fat tails

Suppose the profits of start-ups in a venture-capital portfolio follow a Cauchy distribution (no finite mean or variance). Explain why the average profit across more and more start-ups does not settle down, and what this suggests for heavy-tailed economic outcomes such as wealth or firm revenue.

Show solution

Step 1. The LLN and CLT both need a finite mean (and the CLT a finite variance). The Cauchy has neither.

Step 2. A known property: the average of nn independent Cauchy draws is itself Cauchy with the same spread, so averaging never reduces uncertainty.

Step 3. Intuition: every so often one start-up has a gigantic gain or loss that dominates the whole average (see the running means in the code).

Answer: the portfolio average does not converge. Real outcomes such as wealth have finite but huge variances, so convergence is slow and a few extreme units drive the mean; analysts use logs, winsorising, medians or quantiles.

Exercise 15 · Seeing the CLT in hospital stays

Hospital length of stay is strongly right-skewed: suppose it is exponential with mean 1 week. A health authority audits random samples of 50 patients and records each sample's mean stay. If you simulate 10,000 such audits, what mean, variance and shape should the sample means have?

Show solution

Step 1. For the exponential with mean 1, μ=1\mu = 1 and σ2=1\sigma^2 = 1.

Step 2. E[Xˉ]=μ=1E[\bar X] = \mu = 1 week.

Step 3. Var⁡(Xˉ)=σ2/n=1/50=0.02\operatorname{Var}(\bar X) = \sigma^2/n = 1/50 = 0.02, so sd ≈ 0.141 weeks.

Step 4. Shape: by the CLT, approximately normal. The skewness shrinks from 2 for one patient to about 2/50≈0.282/\sqrt{50} \approx 0.28 for the mean.

Answer: mean 1, variance 0.02, nearly bell-shaped despite the skewed stays (see the code and the CLT simulator).

Verify in Python

import numpy as np
from scipy import stats

rng = np.random.default_rng(2026)
means = rng.exponential(1.0, size=(10_000, 50)).mean(axis=1)
print(f"mean of means {means.mean():.3f} (theory 1), var {means.var():.4f} (theory 0.02)")
print(f"skewness of draws ~2, of means {stats.skew(means):.2f} (theory 2/sqrt(50) = 0.28)")

print("P(Xbar > 53):", round(stats.norm.sf(53, 50, 2), 4))
print("Total claims tail:", round(stats.norm.sf(55_000, 50_000, 3_000), 4))
print("Chebyshev bound 0.25 vs CLT:", round(2 * stats.norm.sf(2), 4))

# Cauchy: running mean never settles
c = rng.standard_cauchy(1_000_000)
print("Cauchy running means:", [round(float(c[:k].mean()), 2) for k in (10**3, 10**4, 10**5, 10**6)])

Key takeaways

  • Sample means are unbiased with standard error σ/n\sigma/\sqrt n.
  • The LLN says they converge to μ\mu; the CLT says their errors are approximately normal.
  • Dependence (clusters) and fat tails weaken both results.

Simulation Lab: Central Limit Theorem Simulator

Open full screen →

Draw thousands of sample means from skewed or bimodal parents and watch the normal shape appear.

0120.511.5sample mean (n = 30)density
4,000 simulated sample meansCLT: N(μ, σ²/n)
Parent distribution
012345
mean of x̄
1.003
μ = 1.000
sd of x̄
0.182
σ/√n = 0.183
skewness of x̄
0.32
normal = 0

4,000 samples of size n. Even when the parent is skewed or lumpy, the sample mean's distribution approaches N(μ, σ²/n). Skewness shrinks like 1/√n.

Day 6Day 8