Quant Memo
Advanced

Conditional Monte Carlo and Rao-Blackwellization

A variance-reduction trick that replaces part of a simulation with an exact formula whenever one exists, so you only simulate the part you genuinely can't compute — and the result is provably never noisier than simulating everything.

Prerequisites: Monte Carlo Integration, The Law of Large Numbers

Simulating something end to end is easy to code but can be wasteful: if part of the calculation could actually be done exactly with a closed-form average, simulating it anyway just adds noise you didn't need to add. Conditional Monte Carlo — the technique behind Rao-Blackwellization — says: whenever a piece of your simulation has a known conditional expectation, replace that piece with its exact formula and simulate only the part left over. The result is mathematically guaranteed to have the same expected value but less variance, for free, every time such a piece exists.

An analogy: a weather forecaster who knows tomorrow's average

Suppose you want to estimate ice cream sales next month by simulating each day: draw a random temperature, then draw random sales conditional on that temperature, and average the results over many simulated days. But suppose you actually know, from a solid model, the exact average sales for any given temperature — no need to simulate that step at all. A smarter approach: simulate only the random temperatures (the part you truly don't know in advance), and for each simulated temperature just plug into the known average-sales formula instead of drawing a noisy random sales figure. You still get the right average sales estimate, but you've removed an entire layer of unnecessary randomness — the sales-given-temperature noise — that was adding variance without adding information.

The idea, one symbol at a time

Suppose you want E[Y]\mathbb{E}[Y] where YY depends on two sources of randomness, and there's an intermediate variable XX such that the conditional expectation g(X)=E[YX]g(X) = \mathbb{E}[Y \mid X] has a known closed form. By the law of total expectation, E[Y]=E[E[YX]]=E[g(X)]\mathbb{E}[Y] = \mathbb{E}[\mathbb{E}[Y \mid X]] = \mathbb{E}[g(X)] — so instead of simulating pairs (X,Y)(X, Y) and averaging the YY's, you can simulate only XX and average g(X)g(X) instead, since both give the same expected value.

The variance comparison is the key result, sometimes called the Rao-Blackwell theorem in this context: by the law of total variance, Var(Y)=E[Var(YX)]+Var(E[YX])=E[Var(YX)]+Var(g(X))\text{Var}(Y) = \mathbb{E}[\text{Var}(Y \mid X)] + \text{Var}(\mathbb{E}[Y \mid X]) = \mathbb{E}[\text{Var}(Y \mid X)] + \text{Var}(g(X)). Since E[Var(YX)]0\mathbb{E}[\text{Var}(Y \mid X)] \geq 0 always, we get

Var(g(X))Var(Y),\text{Var}(g(X)) \le \text{Var}(Y),

meaning the conditional estimator g(X)g(X) has variance at most as large as simulating YY directly — strictly smaller whenever YY has any genuine leftover randomness given XX. In plain English: you've thrown away exactly the noise that carried no information about the answer (the within-XX variation of YY), and kept only the noise that actually mattered (the variation of XX itself).

Worked example: pricing a barrier-dependent payoff

Suppose you simulate a stock path and want the expected payoff of a claim that pays STS_T if the path never crosses a barrier, and 0 if it does. Plain Monte Carlo simulates the full path, checks whether the barrier was crossed, and averages the payoff over many simulated paths — noisy, since each path's "crossed or not" outcome is a coin flip contributing binary noise. Conditional Monte Carlo instead notes that, given the path's terminal value STS_T (or a coarser summary of the path), the exact probability of not having crossed the barrier along the way has a known closed-form formula from reflection-principle arguments for Brownian motion. So instead of simulating the crossing event, you simulate only STS_T, and for each simulated STS_T you multiply by the exact non-crossing probability rather than a simulated 0/1 indicator — replacing binary-outcome noise with a smooth exact number every single path.

The explorer below lets you compare a binomial distribution against different parameters — try shrinking nn toward 1 to see the raw, high-variance coin-flip outcome that conditional Monte Carlo replaces with a smooth exact probability instead.

Distribution · binomial
mean 1.0012outcomes (k) →
mean 1.00std dev 0.71peak at k = 1

Worked example: a numeric variance comparison

Suppose XUniform(0,1)X \sim \text{Uniform}(0, 1) and, given XX, YXBernoulli(X)Y \mid X \sim \text{Bernoulli}(X) (so YY is 0 or 1, with success probability equal to XX itself). Here g(X)=E[YX]=Xg(X) = \mathbb{E}[Y\mid X] = X. Plain Monte Carlo estimates E[Y]\mathbb{E}[Y] by simulating XX, then simulating a coin flip YY with that probability, and averaging the 0/1 outcomes: Var(Y)=E[X(1X)]+Var(X)\text{Var}(Y) = \mathbb{E}[X(1-X)] + \text{Var}(X). With XX uniform on [0,1][0,1], Var(X)=1/120.0833\text{Var}(X) = 1/12 \approx 0.0833 and E[X(1X)]=E[X]E[X2]=0.51/30.1667\mathbb{E}[X(1-X)] = \mathbb{E}[X] - \mathbb{E}[X^2] = 0.5 - 1/3 \approx 0.1667, giving Var(Y)0.25\text{Var}(Y) \approx 0.25. The conditional estimator skips the coin flip and just averages XX directly, giving variance Var(X)0.0833\text{Var}(X) \approx 0.0833 — roughly a threefold reduction in variance from removing the coin-flip noise, using the exact same number of simulated draws of XX.

plain Monte Carlo simulate X simulate Y|X conditional MC simulate X exact g(X) Var(Y) ≈ 0.25 Var(g(X)) ≈ 0.083
Replacing the simulated Y|X step with its exact conditional expectation removes an entire layer of noise, cutting the estimator's variance without changing what it estimates on average.

What this means in practice

Conditional Monte Carlo (also called Rao-Blackwellization when framed as an estimator-improvement principle) shows up in option pricing whenever a sub-piece of the payoff has a known conditional formula — barrier options conditioned on terminal value, Asian options conditioned on a subset of averaging dates — and in particle filtering, where analytically tractable sub-states are integrated out exactly rather than sampled (see particle filters). The general lesson for any simulation project: before writing code that simulates everything, check whether any intermediate step has a known exact conditional average, and if so, plug in the formula instead of a random draw — it is never worse and often much better, for the same computational effort.

Whenever part of a simulation has a known conditional expectation, replacing that simulated piece with its exact formula and simulating only what's left over cannot increase variance and typically reduces it substantially, since it removes exactly the noise that carried no information about the final answer.

The trap is applying conditional Monte Carlo to a variable whose "exact" conditional formula is only an approximation, or forgetting that the technique requires the conditional expectation to be genuinely tractable in closed form — not just plausible-looking. If g(X)=E[YX]g(X) = \mathbb{E}[Y\mid X] is itself estimated with error (say, from a separate small simulation or an approximate formula), you've reintroduced noise you thought you'd eliminated, and the clean variance-reduction guarantee no longer holds. Always verify the conditional expectation step is exact, not merely convenient, before trusting the variance comparison.

Related concepts

Practice in interviews

Further reading

  • Glasserman, Monte Carlo Methods in Financial Engineering, ch. 4
  • Casella, Robert, Rao-Blackwellisation of sampling schemes
ShareTwitterLinkedIn