How it Works
To estimate P(X > t) for X ~ N(0,1) with large t, naive Monte Carlo rarely hits the tail. Importance sampling draws samples from a shifted Gaussian q = N(μ_q, σ_q²) centred near the threshold t. Each sample x_i gets reweighted by w(x_i) = p(x_i)/q(x_i):
The optimal proposal is q*(x) ∝ 1[x>t]·p(x) — a truncated Gaussian on (t,∞). Shifting μ_q to t reduces variance by many orders of magnitude for large t. The ESS (effective sample size) measures efficiency.
Frequently Asked Questions
What is importance sampling?
Importance sampling (IS) is a variance reduction technique that samples from a proposal distribution q instead of the target p. The estimator reweights samples by the likelihood ratio w(x) = p(x)/q(x).
Why is importance sampling useful for rare events?
For rare events (e.g., P(X > 5) for a standard normal X), naive Monte Carlo draws almost no samples from the important tail region. IS shifts the proposal to the region of interest, collecting many more relevant samples.
What is the likelihood ratio (importance weight)?
The importance weight is w(x) = p(x)/q(x). Each sample x drawn from q is multiplied by w(x) to compensate for sampling from the wrong distribution. The IS estimator is (1/N)Σ f(x_i)·w(x_i).
What is the optimal proposal distribution?
The optimal proposal is q*(x) ∝ |f(x)|·p(x), which makes the IS estimator have zero variance. In practice, the optimal q* is not known exactly but can be approximated by shifting/scaling to cover the important region.
What is self-normalised importance sampling?
Self-normalised IS divides by the sum of weights: μ̂_SN = Σ f(x_i)w(x_i) / Σ w(x_i). This makes the estimator consistent even when q is only known up to a normalisation constant, but introduces a small bias.
What is effective sample size (ESS) in IS?
ESS = (Σw_i)² / Σw_i² measures how many equivalent i.i.d. samples from p the IS estimate corresponds to. ESS ≈ N means very low variance; ESS ≪ N indicates weight degeneracy.
What causes weight degeneracy?
Weight degeneracy occurs when a few samples receive nearly all the weight. It happens when p has heavier tails than q, causing extreme weights for occasional samples in the mismatched region.
How is importance sampling used in machine learning?
IS is used in variational inference (IWAE bound), policy gradient methods (off-policy learning), Bayesian model selection, and sequential Monte Carlo (particle filters).
What is the variance reduction factor of IS?
IS reduces variance when Var_q[f·w] < Var_p[f]. The variance ratio equals ESS/N. For the optimal q*, variance is 0. For a Gaussian shifted to cover the rare region, variance reduction can be exponential in the threshold.
What are stratified sampling and control variates?
Stratified sampling divides the input domain into strata and samples each proportionally, reducing variance. Control variates subtract a correlated known-expectation function to reduce estimator variance. Both complement importance sampling.