Variance Reduction Techniques for Monte Carlo
09 April 2022
Standard Monte Carlo (MC) estimates of an expectation \(\mu = \E[f(X)]\) are simple and unbiased, but their standard error shrinks only as \(\mathcal{O}(1/\sqrt{n})\). Cutting the error in half requires four times as many samples. A natural question is whether we can construct other unbiased estimators of the same quantity that achieve strictly lower variance for the same sample budget.
This post gives a concise overview of four workhorse variance-reduction techniques: antithetic variates, stratified sampling, conditioning (Rao–Blackwellization), and control variates (which has its own dedicated deep dive here).
1. Antithetic Variates
Suppose we draw paired samples \((X_i, \widetilde{X}_i)\) where each marginal has the target distribution \(p\), and we form the paired average:
\[\hat{\mu}_{\text{anti}} = \frac{1}{n} \sum_{i=1}^{n} \frac{f(X_i) + f(\widetilde{X}_i)}{2}.\]By linearity of expectation, \(\hat{\mu}_{\text{anti}}\) is unbiased regardless of how \(X_i\) and \(\widetilde{X}_i\) are coupled. Its variance for a single pair is:
\[\Var\!\left[\frac{f(X) + f(\widetilde{X})}{2}\right] = \frac{\sigma^2}{2}\big(1 + \rho\big),\]where \(\sigma^2 = \Var[f(X)]\) and \(\rho = \text{Corr}\big(f(X), f(\widetilde{X})\big)\). Comparing this to two independent samples (variance \(\sigma^2 / 2\)):
- If \(\rho < 0\) (negatively correlated outputs), antithetic sampling reduces variance.
- If \(\rho > 0\), it hurts — in the worst case (\(\rho = 1\)) doubling the variance relative to independent draws.
In practice, antithetic pairs are easiest to construct for symmetric distributions — e.g., \(U \sim \text{Uniform}(0, 1)\) paired with \(\widetilde{U} = 1 - U\), or \(Z \sim \gN(0, I)\) paired with \(\widetilde{Z} = -Z\). Whenever \(f\) is monotonic (or approximately linear around the mean), negatively correlated inputs guarantee \(\rho < 0\); for linear \(f\), \(\rho = -1\) and the variance collapses to \(0\).
2. Stratified Sampling
Instead of drawing all \(n\) samples blindly from \(p(x)\), stratified sampling partitions the domain of \(X\) into \(K\) disjoint regions (strata) \(\gD_1, \dots, \gD_K\) with known probabilities \(\omega_j = \sP(X \in \gD_j)\) summing to \(1\).
Within each stratum \(\gD_j\), the conditional density is \(p_j(x) = \omega_j^{-1} p(x)\,\sI_{x \in \gD_j}\). Drawing \(n_j\) samples from each \(p_j\) yields the stratified estimator:
\[\hat{\mu}_{\text{strat}} = \sum_{j=1}^{K} \omega_j \left(\frac{1}{n_j} \sum_{i=1}^{n_j} f(X_{j,i})\right).\]By the law of total expectation, \(\hat{\mu}_{\text{strat}}\) is unbiased. Its variance is:
\[\Var[\hat{\mu}_{\text{strat}}] = \sum_{j=1}^{K} \frac{\omega_j^2 \sigma_j^2}{n_j},\]where \(\sigma_j^2 = \Var[f(X) \mid X \in \gD_j]\) is the within-stratum variance.
- Proportional allocation (\(n_j = \omega_j n\)) gives \(\Var[\hat{\mu}_{\text{strat}}] = \frac{1}{n}\sum_j \omega_j \sigma_j^2 \le \frac{\sigma^2}{n}\) — by the law of total variance, it can never be worse than plain MC, because it eliminates the between-strata variance completely.
- Neyman (optimal) allocation sets \(n_j \propto \omega_j \sigma_j\), putting more samples in strata where \(f\) varies most.
- Practical caveat: You need to know the stratum probabilities \(\omega_j\) and be able to sample from each conditional \(p_j\). When you know \(\omega_j\) but cannot sample directly from \(p_j\), post-stratification draws from \(p(x)\) as usual and bins samples into strata afterward, recovering most of the variance reduction asymptotically.
3. Conditioning (Rao–Blackwellization)
Suppose the integrand depends on two random variables \((X, Y)\), and we want to estimate \(\E[f(X, Y)]\). If we can integrate out \(Y\) analytically given \(X\), define:
\[h(X) = \E\big[f(X, Y) \mid X\big].\]By the law of iterated expectations, \(\E[h(X)] = \E[f(X, Y)]\), so averaging \(h(X_i)\) is still unbiased. By the law of total variance:
\[\Var[f(X, Y)] = \Var\big[\E[f(X, Y) \mid X]\big] + \E\big[\Var[f(X, Y) \mid X]\big] \ge \Var[h(X)].\]Conditioning is sometimes called derandomization because it removes a source of randomness analytically before Monte Carlo ever runs. It is guaranteed never to increase variance — the only practical trade-off is computational cost: if evaluating the conditional expectation \(h(X)\) is far more expensive than drawing extra samples of \(f(X, Y)\), plain MC can still win per unit of wall-clock time.
A classic RL example is Expected SARSA (or the all-actions policy gradient), where summing over actions weighted by \(\pi(a \mid s)\) analytically instead of sampling a single action \(a \sim \pi(\cdot \mid s)\) Rao–Blackwellizes the update.
4. Control Variates
When we have a correlated auxiliary function \(h(x)\) with known expectation \(\mu_h = \E[h(x)]\), we can form the unbiased estimator:
\[\hat{\mu}_{\text{cv}}(\beta) = \frac{1}{n}\sum_{i=1}^{n} \Big(f(X_i) - \beta\big(h(X_i) - \mu_h\big)\Big).\]At the optimal scaling \(\beta^* = \Cov[f(X), h(X)] / \Var[h(X)]\), the variance drops by a factor of \((1 - \rho_{f,h}^2)\). For a full derivation, Python simulation, and connections to RL baselines, see the dedicated post on Variance Reduction via Control Variates.
Summary Comparison
| Technique | Key Requirement | Guaranteed \(\le\) MC Variance? | Best When |
|---|---|---|---|
| Antithetic variates | Negatively correlated input pairs \((X, \widetilde{X})\) | Only if \(\text{Corr}(f(X), f(\widetilde{X})) < 0\) | \(f\) is monotonic / roughly linear |
| Stratified sampling | Known stratum weights \(\omega_j\) & conditional sampling | Yes (under proportional / Neyman allocation) | \(f\) varies strongly across regions |
| Conditioning | Tractable conditional expectation \(\E[f(X,Y)\mid X]\) | Yes (always) | Part of the integral is analytically tractable |
| Control variates | Correlated \(h(X)\) with known \(\E[h(X)]\) | Yes (at optimal \(\beta^*\)) | A cheap surrogate closely tracks \(f\) |