Quant Memo
Advanced

Importance Sampling

A variance-reduction trick for Monte Carlo. When the outcome you care about is rare, sampling from the true distribution wastes nearly every draw — so sample from one that visits the important region often, then reweight to stay unbiased.

Prerequisites: Monte Carlo Integration, Expected Value

Plain Monte Carlo works by sampling from the true distribution and averaging. That is fine when the thing you want happens often. But suppose you are estimating the probability of a rare event — a 1-in-30,000 tail loss. Sample naively and almost every draw lands nowhere near the tail, contributing a useless zero, and you would need hundreds of thousands of samples just to see the event a handful of times. Importance sampling fixes this by cheating cleverly: draw samples from a different distribution that spends its time where the action is, then correct for the swap so the answer stays exactly right.

The reweighting identity

Say you want the average of f(X)f(X) when XX follows the true density pp. The trick is to multiply and divide by a second density qq that you get to choose:

Ep[f(X)]=Eq ⁣[f(X)p(X)q(X)].E_p[f(X)] = E_q\!\left[f(X)\,\frac{p(X)}{q(X)}\right].

Read this carefully: instead of averaging ff over draws from pp, you average ff times a weight w(X)=p(X)/q(X)w(X) = p(X)/q(X) over draws from qq. The weight — the ratio of how likely the sample was under the truth versus under your sampler — undoes the bias you introduced by sampling from the wrong place. The estimate becomes

Ep[f(X)]1Ni=1Nf(Xi)p(Xi)q(Xi),Xiq.E_p[f(X)] \approx \frac{1}{N}\sum_{i=1}^{N} f(X_i)\,\frac{p(X_i)}{q(X_i)}, \qquad X_i \sim q.

Choose qq to put its mass where fpf \cdot p is large — the region that actually contributes to the answer — and each sample now carries real information instead of a zero.

true p proposal q rare region
Sampling from the true distribution p (green) almost never lands in the shaded rare region. Shift the sampler to a proposal q (amber) centered on that region, draw from it, and reweight each sample by p/q. Now nearly every draw is informative — and the answer is still unbiased.

Sample from a convenient distribution qq instead of the true pp, then reweight each draw by the likelihood ratio w=p/qw = p/q. The average of fwf \cdot w over draws from qq equals the true expectation — you aimed your samples where they matter without introducing any bias.

Worked example: a deep tail probability

You want P(X>4)P(X > 4) for a standard normal XX — the chance of a four-sigma move. The true answer is about 3.17×1053.17 \times 10^{-5}, roughly one in 31,500. Sample naively from N(0,1)N(0,1) and you would draw around 31,500 numbers just to expect a single hit; the estimate would be hopelessly noisy at any practical sample size.

Instead, sample from a proposal shifted right onto the tail: q=N(4,1)q = N(4, 1). Now suppose one draw comes out at x=4.2x = 4.2 — squarely in the region of interest, so f(x)=1f(x) = 1. Its weight is the ratio of the two densities:

w=p(4.2)q(4.2)=exp ⁣(4.222+(4.24)22)=exp ⁣(8.8)1.5×104.w = \frac{p(4.2)}{q(4.2)} = \exp\!\Big(-\tfrac{4.2^2}{2} + \tfrac{(4.2 - 4)^2}{2}\Big) = \exp\!\big(-8.8\big) \approx 1.5 \times 10^{-4}.

Every draw from qq now lands in the tail, and each contributes a small weight around 10410^{-4}; average those weights and you converge on the tiny true probability with a few thousand samples instead of millions. Same answer, a fraction of the compute.

Where it goes wrong

The whole method lives or dies on the choice of qq, and a bad choice is worse than doing nothing.

  • Thin-tailed proposals explode. If qq has lighter tails than pp, then out in the tail the weight p/qp/q blows up, a handful of freak samples dominate the average, and the estimator's variance can become infinite — you get a confident-looking number that is silently garbage. The safe rule: qq should have tails at least as fat as pp wherever ff is nonzero.
  • Coverage is non-negotiable. qq must be able to reach everywhere pfp \cdot f is nonzero. If qq assigns zero probability to a region that actually matters, that region is invisible and the estimate is biased.
  • Weight degeneracy. In high dimensions the weights often become wildly unequal — one sample carries almost all the weight and the rest count for nothing, collapsing your effective sample size. Diagnosing this (via the effective sample size) is part of using the method responsibly.

A proposal with thinner tails than the target makes the weight p/qp/q blow up in the tail, and the estimator's variance can become infinite — a stable-looking answer that is quietly wrong. Always give qq tails at least as heavy as pp over the region that matters.

Pick your proposal qq to imitate the shape of fpf \cdot p — put the sampling mass exactly where the integrand is big. The closer qq matches that product, the smaller the weight variance and the faster you converge.

Importance sampling is how practitioners estimate rare-but-costly quantities: deep-tail value-at-risk and expected shortfall, the price of far-out-of-the-money options, and the loss distributions behind tail-risk hedges — anywhere the events that matter most are the ones you almost never sample.

Related concepts

Practice in interviews

Further reading

  • Glasserman, Monte Carlo Methods in Financial Engineering (ch. 4)
  • Owen, Monte Carlo Theory, Methods and Examples (ch. 9)
ShareTwitterLinkedIn