Why Reweight Simulated Draws?
A likelihood that depends on an unobserved variable often requires integrating that variable out. For example, a model may specify the distribution of a latent effect and the probability of the observed outcome conditional on that effect. The resulting likelihood is an average over the latent-effect distribution. Direct simulation from that distribution can be inefficient when only a small part of its range contributes appreciably to the integral.
Importance sampling addresses this problem by drawing from a different distribution, called a proposal distribution, and correcting each draw with a weight. A useful proposal concentrates draws in regions that matter to the integral. But if the proposal misses important regions or places too little probability there, a few large weights can dominate the estimate. The weighting identity makes the correction exact in expectation; diagnostics help determine whether it is useful in a particular simulation.
In a likelihood integral with latent variable \(u\), a common form is \(L(\theta)=\int p(y\mid u,\theta)f(u\mid\theta)\,du\). Here \(y\) denotes observed data, \(f(u\mid\theta)\) is the latent-variable density, and \(p(y\mid u,\theta)\) is the likelihood conditional on \(u\). The integrand is \(h(u)=p(y\mid u,\theta)f(u\mid\theta)\). A proposal \(q(u)\) then gives weight \(p(y\mid u,\theta)f(u\mid\theta)/q(u)\). The parameter \(\theta\) is held fixed while estimating this integral.
The Weighting Identity and Its Conditions
The identity follows by multiplying and dividing the integrand by the proposal density. The condition on support is essential: if \(h(z)>0\) in a region where \(q(z)=0\), no proposal draw can represent that region, and the integral cannot be recovered by reweighting.
Consequently, under the support condition and a finite integral, the sample average of the weights is unbiased: its expectation under repeated independent draws from \(q\) equals \(I\). To have finite variance, a stronger condition is needed: \(\int h(z)^2/q(z)\,dz<\infty\). When this holds, the variance of the estimate is the variance of one weight divided by \(N\). Thus an unbiased estimator can still be highly variable if the weights are dispersed.
Write the likelihood integral as \(I=\int h(z)\,dz\), including every density and likelihood contribution in \(h\).
Choose a simulable density \(q\) that is positive throughout the region where \(h\) is positive and gives useful coverage of the important parts of that region.
For each draw \(Z_i\), calculate \(w_i=h(Z_i)/q(Z_i)\). Average the weights to estimate the integral.
Check whether a small number of draws dominate. Weight dispersion can make the estimate unstable even when the support condition is satisfied.
Worked Example: Estimating a Simple Integral
Suppose the target is the hypothetical integral \(I=\int_0^1 2x\,dx\). Choose the uniform density \(q(x)=1\) on \([0,1]\), and suppose three independent proposal draws happen to be \(0.2\), \(0.5\), and \(0.9\). The proposal is positive wherever the integrand is positive, so the support condition holds.
For each draw, the importance weight is \(w(x)=2x/q(x)=2x\). The three weights are \(0.4\), \(1.0\), and \(1.8\), giving
The exact integral is \(\int_0^1 2x\,dx=[x^2]_0^1=1\). This particular estimate is above the exact value, which is possible for a finite random sample. Unbiasedness describes the average estimate over repeated samples, not a guarantee that each realized estimate equals the integral.
Importance Sampling for a Latent-Variable Likelihood
The same calculation applies directly to a likelihood integral. The target integrand includes both the probability of the observed data conditional on the latent variable and the latent variable's model density. The proposal replaces the latter as the simulation distribution, but the ratio of target density to proposal density must remain in each weight.
Worked Example: A Binary Outcome With a Discrete Latent Effect
Consider a hypothetical model with latent effect \(U\in\{-1,+1\}\), where each value has probability \(0.5\). Conditional on \(U=u\), a binary outcome has success probability \(\operatorname{logit}^{-1}(u)=1/(1+e^{-u})\). The observed outcome is a success. The likelihood integral (a sum in this discrete case) is
Instead of drawing from the equal-probability latent distribution, use the proposal \(q(+1)=0.8\), \(q(-1)=0.2\). Both possible latent values have positive proposal probability, so neither part of the likelihood is omitted. The importance weight for a draw \(u\) is \(p(y=1\mid u)P(U=u)/q(u)\). Thus
Suppose four independent proposal draws are \(+1,+1,+1,-1\). The estimated likelihood is
This estimate is close to, but not exactly, the likelihood \(0.5000\). The higher proposal probability for \(+1\) does not change the target likelihood because its conditional likelihood contribution is reduced by the corresponding weight. Across repeated samples from this proposal, the average of the weighted contributions equals \(0.5000\).
Diagnosing Weight Dispersion
The weights provide a direct diagnostic of proposal performance. If they are nearly equal, each draw contributes similarly to the estimate. If one weight is much larger than the others, the estimate is sensitive to whether that draw appears in the simulation. Equal weights are not required for validity, but extreme dispersion can make a formally unbiased estimate practically unreliable.
A commonly used summary is the effective sample size (ESS) of the importance weights. For nonnegative weights \(w_1,\ldots,w_N\), define
The ESS is at most \(N\), and it equals \(N\) when all weights are equal. It approaches one when nearly all the total weight is concentrated in a single draw. It is a summary of weight concentration, not a literal count of independent observations and not, by itself, a confidence interval or a guarantee of accuracy.
Worked Example: Comparing Two Sets of Importance Weights
Suppose two hypothetical proposals are used for the same target integral, each with five draws. One produces weights \(0.01, 0.02, 0.02, 0.05, 4.00\). The sum is \(4.10\), and the sum of squared weights is \(0.01^2+0.02^2+0.02^2+0.05^2+4.00^2=16.0034\). Its ESS is therefore
Although five draws were generated, their weight concentration is comparable to only about one equally weighted draw. The largest weight contributes \(4.00/4.10=0.9756\), or about 97.56% of the total weight.
A second proposal produces weights \(0.60, 0.80, 1.00, 1.10, 1.20\). Their sum is \(4.70\), and their squared sum is \(4.65\), so
The second set is much less concentrated, suggesting that its proposal is more efficient for this integral in these simulations. This comparison is a diagnostic, not proof that the second estimate is accurate: a proposal can have moderate observed weight dispersion while failing to cover a region that was never sampled. Support, substantive knowledge of the integrand, and stability across repeated runs still matter.
Choosing and Using a Proposal
A good proposal places draws where the target integrand contributes substantially, while retaining enough probability in all regions needed for support and tail coverage. In a likelihood integral, this often means concentrating draws in latent-variable regions compatible with the observed data, rather than drawing only from the unconditional latent-variable distribution. The proposal may depend on the observed data and on the parameter value at which the likelihood is evaluated; the weight must use the actual proposal density that generated each draw.
There is no universal proposal that is best for every parameter value or data set. A proposal that works well for one likelihood evaluation can yield dispersed weights for another. A practical check is to inspect maximum normalized weight, ESS, and changes in estimates across independent batches or sensible alternative proposals. A low ESS or a single dominant weight is a warning to revise the proposal or increase simulation effort, not a mechanical rule that identifies the correction.
For very small likelihood contributions, it is useful to calculate log weights, \(\log w_i=\log h(Z_i)-\log q(Z_i)\), rather than forming tiny ratios directly. To sum positive weights stably, let \(a=\max_i\log w_i\); then \(\log\sum_i w_i=a+\log\sum_i\exp(\log w_i-a)\). The log of the estimated integral is this log-sum minus \(\log N\). In general, the logarithm of an unbiased likelihood estimate is not itself unbiased: because the logarithm is concave, Jensen's inequality gives \(E[\log\hat I_{\mathrm{IS}}]\leq\log I\), when the expectations exist. This distinction matters when estimates are passed into a log-likelihood calculation.
For ratios of integrals, a related estimator uses normalized importance weights. For example, if the target expectation is \(E_f[a(Z)]\), draw from \(q\), set \(w_i=f(Z_i)/q(Z_i)\), and estimate it by \(\sum_iw_i a(Z_i)/\sum_iw_i\). This self-normalized estimator is generally biased at finite \(N\), though it is consistent under suitable conditions. It should not be confused with the unbiased sample average used to estimate a single integral.
Common Mistakes and Key Takeaway
- Leaving out the correction. Averaging \(h(Z_i)\) when draws come from \(q\) generally estimates an integral under \(q\), not \(\int h(z)\,dz\). Use \(h(Z_i)/q(Z_i)\).
- Assuming more draws fix missing support. If \(q(z)=0\) where \(h(z)>0\), no number of draws from \(q\) can recover that part of the integral. Choose a proposal with adequate support.
- Treating a large ESS as proof of accuracy. ESS measures observed weight concentration. It cannot reveal an important region that the proposal never visits.
- Calling the realized estimate unbiased. Unbiasedness is a repeated-sampling property. A single importance-sampling estimate may be above or below the integral.
Check Your Understanding
Try these questions before moving on.
- State the support condition needed for the importance-sampling identity, and explain what can go wrong if it fails.
- For \(I=\int h(z)\,dz\), what quantity should be averaged when draws are generated from density \(q\)?
- Why can an unbiased importance-sampling estimator still have large variance?
- What does an ESS close to one suggest about the observed weights, and what does it not establish?
- Why is the logarithm of an unbiased likelihood estimate generally not an unbiased estimate of the log likelihood?