Week 03 · Law of large numbers and central limit theorem
Separate convergence of an average from the shape of its sampling distribution.
← Week 2 · Subject contents · Week 4 →
Separate convergence of an average from the shape of its sampling distribution.
Work through the problem
Take exponentially distributed waiting times with mean 2 seconds and standard deviation 2 seconds. The law of large numbers says the sample mean approaches 2 as n grows under these assumptions. The central limit theorem describes the shape after centering and scaling. Z = √n (X̄−2)/2 approaches a standard normal distribution.
At n = 100 a mean of 2.2 seconds gives Z = 1. The distribution of the original waits is still skewed. Standardizing the mean retains fluctuations so their distribution is visible. A heavy-tailed process without finite variance requires different reasoning.
Standardized means of 100 exponential waits.
Run the Python lab
import numpy as np
rng = np.random.default_rng(22)
for n in [1, 10, 100]:
averages = rng.exponential(2, size=(10000, n)).mean(axis=1)
z = np.sqrt(n) * (averages - 2) / 2
skew = np.mean(((z - z.mean()) / z.std())**3)
print(n, round(averages.std(), 3), round(skew, 2))
assert abs(skew) < .35
Output from the lab
1 2.006 2.15
10 0.633 0.65
100 0.201 0.25
Would an average wait of 2.4 seconds trigger an alarm?
Suppose 100 independent requests have exponential waits with mean 2 seconds. The standard deviation of one wait is also 2 seconds. The standard error of their average is 2 / √100 = 0.20 seconds. An observed average of 2.4 seconds sits two standard errors above the mean.
The normal approximation puts 2.28% of batches at or above that threshold. Under the exponential model, the exact answer is 2.79%. To see why we can calculate it, imagine each wait as the gap between successive arrivals. An average of at least 2.4 seconds means the hundredth arrival takes at least 240 seconds. That corresponds to at most 99 arrivals by then, apart from a tie of probability zero. The arrival count has a Poisson distribution with mean 240 / 2 = 120.
Download the Week 3 calculation and run it with Python 3. It uses the standard library.
python batch_waits.py
Change the assumption. Suppose the same random delay gets copied to all 100 requests. Averaging 100 copies returns exactly that one delay. Its standard deviation stays at 2 seconds. Under this shared exponential delay, the chance of reaching 2.4 seconds is exp(−2.4 / 2), about 30%. The threshold stayed fixed while the dependence changed the alarm rate. None of these rates tells us the probability of an outage given an alarm.
Practice
- What happens to standard error if n grows from 100 to 400?
Check your reasoning
- It drops from 0.20 seconds to 0.10 seconds under the same model.