Sampling Distributions and the Central Limit Theorem
The previous chapters computed expectations and variances from distributions we knew exactly. In practice the distribution is unknown, and all we have is a sample of data drawn from it. A number computed from a random sample is itself random, because a different sample would give a different number. The distribution of that number across all the samples we could have drawn is its sampling distribution, and it tells us how far the number is likely to be from the quantity we actually care about.
This chapter covers
- populations, i.i.d. samples and statistics,
- the mean, variance and standard error of the sample mean,
- the sample variance and why it divides by ,
- the law of large numbers, and
- the central limit theorem, with a simulator to try it.
Populations and Samples
The population is the distribution we want to learn about. It might be every roll a particular d20 could produce, the returns an agent collects from a state under a fixed policy, or the final score of an RL algorithm across every random seed it could be run with.
A random sample of size is a collection of random variables that are independent and identically distributed (i.i.d.). Identically distributed means each follows the population distribution, with mean and variance . Independent means that the value of one doesn't change the probabilities of the others, as with separate rolls of a die or separate training runs with different seeds.
Statistics and Their Sampling Distributions
A statistic is any quantity computed from the sample. The two most common are the sample mean and the sample variance,
Roll a d20 ten times and average the results, and you might get . Roll it ten more times and you might get . Each batch of ten rolls gives a different , and the histogram of many such averages approximates the sampling distribution of for .
The Sample Mean
The rules from chapter 4 give the center and spread of the sampling distribution of without knowing anything else about the population. Linearity gives its mean,
so the sample mean is centered on the population mean. Because the are independent, their variances add, and gives
The standard deviation of the sample mean is called the standard error,
The standard error shrinks with the square root of the sample size, so halving it takes four times as much data. The average of 25 d20 rolls has a standard error of , while a single roll has a standard deviation of .
The Sample Variance
The population variance is usually unknown too, and the sample variance estimates it. The division by rather than makes . The deviations are measured from , which is computed from the same data and so sits closer to the sample than does. Dividing by would therefore underestimate on average.
Replacing with gives the estimated standard error . When a paper shows a learning curve averaged over independent runs with a shaded band of plus or minus one standard error, this is the quantity behind the band.
The Law of Large Numbers
The variance of goes to zero as grows, so the sample mean settles on the population mean. The law of large numbers states that for any tolerance ,
This is what justifies estimating an expectation by an average. In RL, the sample-average estimate of an action's value in a multi-armed bandit converges to the true value as the action is tried more often, and Monte Carlo methods estimate the value of a state by averaging the returns observed after visiting it.
The Central Limit Theorem
The law of large numbers says that approaches , and the central limit theorem (CLT) describes the shape of the remaining error. If are i.i.d. with mean and finite variance , then the standardized sample mean approaches the standard normal distribution,
where is the CDF of the standard normal. In practice, for large ,
What makes the theorem remarkable is that it doesn't depend on the shape of the population. The population can be discrete, skewed or lumpy, and as long as its variance is finite, the average of enough samples is approximately normal.
How large needs to be does depend on the population. The often-quoted "" is a rule of thumb, not part of the theorem. Symmetric populations like a d20 roll converge after a handful of samples, while skewed ones need many more. For a Bernoulli population, a common guideline is that both and should be at least 10, which for the crit indicator with means . Populations with infinite variance, such as the Cauchy distribution, don't satisfy the theorem at all.
The CLT is the reason the normal distribution is everywhere in statistics. It implies, for example, that lands within standard errors of about 95% of the time, which is the starting point for confidence intervals.
Try It
Start with the critical-hit population and , then draw 1,000 samples. With one roll per sample, the "means" are just zeros and ones. Now increase to 5, 30 and 100 and draw again. The histogram becomes smoother and closer to the normal curve, but it stays visibly skewed at . Then switch to the d20 roll, where the bell shape already appears at . In every case, the readouts below the plots match and . The right-hand plot zooms in as grows, so watch its axis to see the sample means concentrate.
Population distribution
Means of 0 samples of size 1
- Mean of the sample means
- – (population mean μ = 0.050)
- Standard deviation of the sample means
- – (standard error σ/√n = 0.218)
Recap
- A random sample is a set of i.i.d. draws from the population, and a statistic is any number computed from it.
- A statistic varies from sample to sample, and its distribution across samples is its sampling distribution.
- The sample mean has mean and standard error .
- The sample variance divides by so that it is centered on .
- The law of large numbers says converges to .
- The central limit theorem says is approximately for large , whatever the population's shape, as long as its variance is finite.
1. are i.i.d. with variance . What is the variance of the sample mean ?
2. You report the average score of an RL agent over 10 seeds. How many seeds would you need to halve the standard error?
3. What does the central limit theorem say?
What's Next
A chapter on Monte Carlo estimation is planned next. It turns these results into a general recipe for estimating expectations from samples, including how to update an average one sample at a time and how to reweight samples drawn from the wrong distribution. Both ideas are central to the RL notes, starting with the incremental action-value estimates in multi-armed bandits.