Back to AI Math Mind Map
中文·English
📐 AI MathID: importance-sampling

Importance Sampling

重要性采样
🎯Core Definition
Importance Sampling estimates Ep[f]\mathbb{E}_p[f] without sampling from pp directly: when pp is hard to sample, draw from an easy qq and reweight,
📌Overview
Ep[f]=f(x)p(x)dx=f(x)p(x)q(x)q(x)dx=Eq[f(x)w(x)],w(x)=p(x)q(x),\mathbb{E}_p[f] = \int f(x) p(x) \, dx = \int f(x) \frac{p(x)}{q(x)} q(x) \, dx = \mathbb{E}_q[f(x) w(x)], \quad w(x) = \frac{p(x)}{q(x)},
📌Overview
the weight w=p/qw = p/q corrects the mismatch between proposal and target; the sample mean μ^=1ni=1nf(xi)w(xi)\hat\mu = \frac{1}{n} \sum_{i=1}^{n} f(x_i) w(x_i) is unbiased. Its variance is
📌Overview
Varq[fw]=Eq[(fw)2](Ep[f])2,\mathrm{Var}_q[f w] = \mathbb{E}_q[(f w)^2] - (\mathbb{E}_p[f])^2,
📌Overview
which explodes (extreme-weight problem) when qq has thinner tails than pp, making the ratio ww unbounded.
💡Use Cases
Bayesian posterior expectations, off-policy reinforcement learning (importance ratio π(as)/μ(as)\pi(a \mid s) / \mu(a \mid s)), and variance reduction in Monte Carlo integration; interviews often probe the weight formula, variance conditions and the optimal proposal.
Key Problems Solved
expectations without drawing target samples, and one batch of qq-samples serves many target distributions (off-policy reuse); the theoretically optimal proposal q(x)p(x)f(x)q^*(x) \propto p(x) |f(x)| makes fwfw constant with zero variance, but its normalization is unknown and it still requires sampling from pfp|f|, so in practice one uses heavy-tailed proposals and monitors the effective sample size ESS=1/iw^i2ESS = 1 / \sum_i \hat{w}_i^2 to guard against weight collapse.
🎯5 High-Frequency Exam Points
1
Derive Ep[f]=Eq[fw]\mathbb{E}_p[f] = \mathbb{E}_q[f w] with weight w=p/qw = p/q; why is the sample-mean estimator unbiased?
2
What is the variance formula Varq[fw]\mathrm{Var}_q[f w]? Why does a mismatched qq blow up the variance?
3
What is the optimal proposal? Why does it drive variance to 0, and why can't it be used in practice?
4
How is the effective sample size ESS=1/w^i2ESS = 1/\sum \hat{w}_i^2 defined and what does it measure?
5
Importance sampling vs rejection sampling: estimating expectations vs generating samples; weighted average vs 0/1 acceptance?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Importance Sampling"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardRejection SamplingNext CardMarkov Chain & Detailed Balance

🔗 More AI Math Knowledge Cards

Adam/AdamW MathBayesian InferenceBias-Variance DecompositionBootstrap