The interview problem
You estimate average reward under a target distribution using samples from a different proposal distribution. The estimator is theoretically unbiased, yet successive batches disagree wildly. Explain why, calculate the variance in a two-state example, and compare more sampling, self-normalization and weight clipping.
Original fundamentals practice, not a reported interview. All distributions and calculations are invented. Technical reference retrieved September 27, 2026.
1. Write the target before the estimator
Let p be the target probability mass function, q the sampling distribution and f the measured quantity. We want μ = Σ p(x)f(x). Draw independent Xᵢ from q and use weights w(x) = p(x)/q(x). The ordinary estimator is Σᵢ w(Xᵢ)f(Xᵢ)/n: sum the weighted observations and divide once by the number of samples.
The identity E_q[wf] = Σ q(x)p(x)f(x)/q(x) = μ requires proposal support wherever the target contribution is nonzero. If q assigns zero probability to an important region, no amount of reweighting observed samples recovers its missing contribution. For general-purpose reuse, require support wherever p is positive.
Unbiasedness is a statement about repeated datasets. It does not say any one dataset is close to the answer. To use the usual finite-variance standard error, E_q[(wf)²] must also be finite. Finite mean alone is insufficient.
2. Calculate an unstable but unbiased estimate
Take states A and B. The target gives each probability 0.5, while q(A) = 0.99 and q(B) = 0.01. Rewards are f(A) = 0 and f(B) = 1, so the target mean is 0.5. Weights are 50/99 for A and 50 for B.
A single weighted reward Y is zero with probability 0.99 and 50 with probability 0.01. Its expectation is 0.5. Its second moment is 0.01 × 50² = 25, giving variance 25 − 0.5² = 24.75. With 100 independent samples, the estimator's variance is 0.2475 and standard deviation approximately 0.4975.
If K is the number of B observations, the estimate is 50K/100 = K/2. It is zero when K = 0, 0.5 when K = 1 and 1.5 when K = 3. An ordinary importance estimate can exceed the reward range even though the true mean cannot.
The probability of seeing no B in 100 draws is 0.99¹⁰⁰ ≈ 36.6%. In such a batch, all observed weighted rewards are zero. A naive sample-based standard error also becomes zero, missing the unsampled rare contribution. Resampling that batch cannot invent a B observation.
3. Use effective sample size as a warning
The common weight diagnostic ESS = (Σw)²/Σw² measures concentration when the weight sum is nonzero. In a 100-sample batch with one B and 99 A observations, weights sum to 100. Squared weights sum to 2,500 + 99 × (50/99)² ≈ 2,525.25, so ESS ≈ 3.96.
That small value warns that one observation dominates. But if the same sample has no B, all weights are equal and ESS is 100, despite the estimate being zero instead of 0.5. A favorable empirical ESS does not establish that rare important regions were sampled.
Report support coverage, maximum weight, concentration by slice and weighted contributions wf as well as ESS. A weight-only statistic ignores the reward function. Correlated observations also invalidate treating n raw rows as independent; cluster-aware uncertainty must follow the sampling unit.
4. Compare self-normalization carefully
The self-normalized estimator divides Σwf by Σw. With positive weights it stays within the observed reward range. It is generally biased at finite n because the numerator and denominator are both random, though it can be consistent under suitable conditions.
For n = 1 in this example, the weight cancels: the estimate is just f(X). Its expectation is therefore 0.01, not 0.5. This is a deliberately extreme demonstration that normalization does not preserve ordinary importance sampling's unbiasedness.
With 100 samples and K = 1, numerator is 50 and denominator is 100, giving 0.5. With K = 3, numerator is 150 and denominator is 150 + 97 × 50/99 ≈ 198.99, giving about 0.7538 rather than the ordinary estimate 1.5. With no B, both methods return zero. Normalization limits extremes but does not manufacture missing coverage.
5. Make clipping bias explicit
Suppose ordinary weights are capped at 10. A's weight is unchanged and B's becomes 10. Expected clipped weighted reward is 0.01 × 10 = 0.1, so bias relative to the target mean is −0.4. The estimate is less volatile partly because most of B's target contribution has been removed.
For nonnegative f, ordinary clipping reduces the expected contribution by E_q[(w − c)₊f] at threshold c. For signed quantities, the direction of bias need not be downward. Clipping followed by self-normalization is a different estimator with a different bias; do not borrow the ordinary clipping calculation for it.
Choose thresholds using a declared procedure and report sensitivity. Selecting the threshold that gives the most appealing result on the same evaluation data adds another source of optimism. A clipped number can be useful, but label its assumptions and compare it with the unclipped estimate.
6. Repair the sampling design when possible
For this toy problem, sampling from p itself gives Bernoulli rewards with variance 0.25 per draw, versus 24.75 for the original weighted reward: a 99-fold variance reduction at equal n. With n = 100, direct sampling has standard deviation 0.05. Improving coverage can matter far more than a modest increase in batch size.
If the proposal must remain q, reducing the theoretical standard deviation below 0.05 requires n greater than 24.75/0.05² = 9,900 independent draws. This calculation assumes the known toy distribution; it is not a reliable sample-size prescription when tail behavior is unknown.
Use stratified collection or an exploration mixture when operationally feasible, recording actual sampling probabilities. A mixture that assigns some mass to the target can protect support, but must respect the application's constraints. When data collection is fixed, state which target questions the available overlap can support instead of treating an unstable estimate as decisive.
7. Present the decision and limitations
Start the diagnosis with the estimand, sampling unit and probability provenance. Verify support, then inspect weight and contribution tails. Compare ordinary, normalized and clipped results with their differing assumptions. Repeat on independent data where possible, and avoid interpreting a narrow interval from a sample with missing rare events as strong evidence.
Follow-ups: Why can ESS look perfect in the no-B batch? Why can an unbiased estimate exceed one? How does clipping affect a signed reward? What changes if rows share users or come from an adaptive logging policy?
Score 0–2 each for the expectation identity, variance calculation, ESS limitations, normalization/clipping bias and an actionable collection or reporting plan.
Sources and next steps
- Art Owen: Monte Carlo theory, methods and examples, importance sampling chapter — importance sampling and its variance and normalization trade-offs.
- Goodfellow, Bengio and Courville: Deep Learning, Monte Carlo methods — sampling estimates and importance sampling.
All two-state examples, numerical comparisons and diagnostic counterexamples are original derivations. For policy-evaluation context, see selection bias.
Continue your preparation
Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.