Simulating rare events: importance sampling
Tail risk, deep out-of-the-money options and default probabilities all ask about events that rarely happen. Plain Monte Carlo spends almost all of its samples where nothing interesting happens. Importance sampling turns that around: sample from a distribution that hits the rare event often, and correct for the cheating with a weight on every sample.
Plain Monte Carlo wastes its draws
Estimate for a standard normal Z: the true value is . With 10,000 draws you expect 0.3 hits, so most runs return exactly zero. The relative error of plain Monte Carlo is about (step 3). To estimate p to 10%, you need , about 3.2 million draws. At 5σ, about 350 million.
The draws aren’t wasted because the computer is slow; they’re wasted because almost all of them land where the indicator is zero and teach you nothing about the tail.
Sample where the action is, then reweight
Instead of drawing X from N(0, 1), draw it from N(θ, 1) with θ near the threshold. Now about half the draws land past c. Each one is wrong by a known amount: it was drawn too often, by a factor . Multiply by the inverse, the likelihood ratio in step 2, and the average is unbiased again:
Its variance has a closed form. The second moment is , so
Sample from N(θ, 1) instead of N(0, 1)
Relative error with 10,000 draws vs θ
At θ = 0 (plain Monte Carlo) the error curve starts high: for c = 4, a 178% relative error with 10,000 draws. It drops steeply as θ moves towards c, bottoms out near θ = c at about 2%, and climbs again if you overshoot: then most samples land far beyond c, where the weights are tiny and very uneven. With θ = c, the relative error stays near 2% from c = 2 to c = 5, while plain Monte Carlo goes from 6.5% to hopeless.
import numpy as np
from scipy.stats import norm
rng = np.random.default_rng(0)
N, c = 10_000, 4.0
p = norm.sf(c) # 3.17e-5
z = rng.standard_normal(N)
plain = (z > c).mean() # usually 0
x = rng.standard_normal(N) + c # sample from N(c, 1)
w = (x > c) * np.exp(-c * x + c**2 / 2) # likelihood ratio
print(p, plain, w.mean(), w.std() / np.sqrt(N) / p) # IS estimate within ~2%The same trick in option pricing and risk
- Deep out-of-the-money options. Shift the drift of the simulated Brownian motion so more paths finish in the money, and weight each path by the Girsanov density . It’s the same calculation as above, applied to the terminal normal draw.
- Portfolio VaR and credit losses. Tilt the factor distribution towards the stress scenarios that drive large losses (Glasserman, Heidelberger and Shahabuddin did this for portfolio credit risk).
- Barrier hits and default times. Push paths towards the barrier, weight them back.
The choice of tilt is the craft. A good rule for tail probabilities is to make the rare event typical under the new measure: centre g on the most likely way the event happens.
Where people slip in interviews
- Forgetting the weights. Sampling from g without the likelihood ratio estimates the probability under g, not under f.
- Overshooting. Tilting too far puts samples in the far tail, where weights vary by orders of magnitude; the variance blows up.
- Choosing g with thinner tails than f. If g is near zero where f·1_A isn’t, the weights explode, and the variance can be infinite.
- Reporting the plain-MC error formula. The IS estimator has its own variance; compute it from the weighted samples.
Try these before you open the answer
Warm-upDerive the likelihood ratio φ(x)/φ(x − θ).Show answer
Plain MCHow many plain Monte Carlo draws do you need to estimate P(Z > 3) ≈ 0.00135 to 5% relative error?Show answer
WeightsWith θ = c = 4, what weight does a draw at exactly x = 4 get? And at x = 5?Show answer
and . Draws further out count for much less.
UnbiasedShow that E_θ[1{X > c} e^{−θX + θ²/2}] = P(Z > c).Show answer
using the identity from the warm-up.
OptionsYou want the price of a digital that pays 1 if a stock, now 100, finishes above 200 in a year (20% vol, zero rates). How would you shift the simulation?Show answer
The digital pays when . Sample Z from N(3.57, 1) and weight each path by . The price is about .
The relative errors were checked with 10,000-draw simulations at c = 2, 3, 4 and 5. The figure’s error curve is the exact formula above.