Importance sampling and effective sample size
Reweight independent proposal draws while checking support, tail behavior, ratio bias, and the limits of weight diagnostics.
On this page
The question for today
What you’ll understand
- Derive ordinary and self-normalized importance estimators.
- Calculate normalized weights and their concentration-based ESS.
- Identify missing support and unstable tails that an attractive diagnostic can conceal.
Importance sampling replaces difficult target draws with easier proposal draws and corrects their distribution through weights. It can estimate posterior expectations or normalizing constants, but the correction works only where the proposal can reach the relevant target mass. A proposal that rarely visits important regions produces volatile weights and misleadingly stable short runs. Understanding this method requires separating a valid expectation identity, a finite-sample estimator, an asymptotic guarantee under stated integrability, and a diagnostic computed only from the draws actually obtained.
A change of probability measure
Let a normalized target density be and proposal density be on a common base measure. Require proposal positivity wherever the target contribution matters. For independent draws from , multiplying by changes its proposal expectation into the target expectation. Absolute integrability supports the expectation identity and a law of large numbers; a finite second moment of the weighted integrand is needed for the usual independent-sample variance and central limit analysis. Correct algebra does not ensure those moments are finite.
A proposal with lighter tails than the target can produce enormous weights in rare regions. Drawing more points in an already overrepresented region does not fix a missing-support defect, because its contribution is never seen. Proposal design should address the integrand too: a rare-event probability and a posterior mean can need different proposals. On finite support all relevant moments are finite if every target state has positive proposal probability, but the variance can still be so large that a small sample is practically uninformative.
Unknown normalizers lead to a ratio
For an unnormalized target with finite positive integral, compute weights and normalize them by their sum. The ratio of weighted function sum to weight sum cancels the unknown target normalizer. Under proposal support coverage and the relevant integrability, separate laws of large numbers give consistency. The ratio is generally biased for finite sample size, even when the numerator and denominator separately estimate their integrals without bias. Denominator zero must also be excluded or handled as a failed sample.
Evaluate weights on the logarithmic scale when products of many densities underflow. Subtracting a common maximum log weight before exponentiating preserves normalized weights, although it does not repair inadequate overlap. The sample average of unnormalized weights estimates the target normalizer if all its constants were retained. Self-normalization can obscure those constants deliberately for an expectation, so a routine returning only normalized weights does not automatically provide a marginal likelihood estimate. Keep the target and proposal density conventions explicit.
ESS is useful evidence with boundaries
Weight ESS is largest when the observed weights are equal and approaches one when one draw dominates. It is a convenient warning about concentration, but it is not a universal count of independent target observations for every function. Error also depends on how the chosen function varies with the weights, and an unseen important region can leave all observed weights deceptively similar. Distinguish this diagnostic from autocorrelation-based MCMC ESS, which measures a different source of Monte Carlo inefficiency.
A practical investigation repeats sampling with different seeds and stronger proposals, examines the largest weights, and checks estimates against analytical cases or another method. Tail diagnostics can warn about unstable importance ratios, but finite diagnostics cannot certify complete support coverage or finite population moments. If the estimate changes substantially after one exceptional draw, treat the earlier apparent precision cautiously. Increasing proposal coverage or changing the estimator may be more effective than simply reporting a larger nominal sample size with the same unstable weighting mechanism.
Work it through
A rare proposal success dominates
The target is Bernoulli(0.8), the proposal is Bernoulli(0.2), and four independent proposal draws happen to be (1,0,0,0). Estimate the target success probability by self-normalized importance sampling and calculate weight ESS.
The success weight is 0.8/0.2=4. Each failure weight is 0.2/0.8=0.25. The sum of weights is 4.75, or 19/4, and the sum of their squares is 16+3/16=259/16.
Only the success draw contributes to the weighted indicator numerator, so the self-normalized estimate is 4/(19/4)=16/19, approximately 0.8421. This realized estimate need not equal the true target probability 0.8.
Weight ESS is (19/4) squared divided by 259/16, equal to 361/259, approximately 1.394. For comparison, ordinary importance sampling with the normalized target gives numerator 4 divided by four draws, or 1, in this realization.
The self-normalized estimate is 16/19 with weight ESS about 1.394 out of four draws. The ordinary estimator is unbiased across repeated samples, not guaranteed exact or constrained to the parameter's natural range in every realization.
The living notebook
Explore the model
Interactive lab · probability
Inspect target-proposal overlap
Pause and Reset, then set both controls to p=0.20 and n=1; predict masses (0.80,0.20) for the proposal. Reset and set p=0.80 and n=1; predict target masses (0.20,0.80). Form the two target/proposal ratios yourself and compare 0.25 with 4. These are exact masses, not simulated importance draws or a live ESS estimate.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA proposal that makes target-important states uncommon produces large correction weights when those states finally appear.
Pause & reason
Check your understanding
Your turn
Try it yourself
Three proposal draws have unnormalized importance weights (1,1,2). An indicator function is zero at the first two and one at the third. Find its self-normalized estimate and weight ESS. What happens to both if every weight is multiplied by seven?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Compute the weight sum and sum of squared weights separately; common scale factors should cancel.
Compare with the solution
Normalized weights are (1/4,1/4,1/2), so the indicator estimate is 1/2. The squared weights sum to 1+1+4=6 and their sum is four, giving ESS=16/6=8/3. Multiplying all weights by seven leaves both quantities unchanged because their numerators and denominators acquire matching scale factors. This scale invariance is why unknown normalizers cancel for posterior expectations; it does not establish that the proposal has adequate support or that the estimate is close to the true expectation.
Keep the idea
Take it with you
- Importance weighting requires proposal support wherever target contributions matter.
- Self-normalized estimates are consistent under suitable assumptions but generally biased at finite N.
- Weight ESS is a concentration diagnostic rather than a universal accuracy certificate.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.