← Back to AI Math Mind Map
📐 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 μ^=1n∑i=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 π(a∣s)/μ(a∣s)\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 p∣f∣p|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.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Importance Sampling.
Use Cases
In production engineering, what are the primary use cases for Importance Sampling and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
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
🎯
Verify Mastery: Practice Exam Questions for "Importance Sampling"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardRejection SamplingNext Card →Markov Chain & Detailed Balance

🔗 More AI Math Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/Math/card/importance-sampling
中文速览与面试要点

重要性采样 (Importance Sampling)

定义: 重要性采样 (Importance Sampling) 估计期望 E_p[f] 而不直接从 p 采样:当 p 难采样时,改从易采样的 q 采样并重加权, E_p[f] = f(x) p(x) \, dx = f(x) p(x)q(x) q(x) \, dx = E_q[f(x) w(x)], w(x) = p(x)q(x), 权重 w = p/q 校正提议分布与目标的偏差;用样本均值 = 1n _i=1^n f(x_i) w(x_i) 得到无偏估计。方差为 Var_q[f w] = E_q[(f w)^2] - ( E_p[f])^2, 当 q 尾部比 p 薄、比值 w 不可控时方差爆炸(极端权重问题)。 使用场景: 贝叶斯后验期望、off-policy 强化学习(重要性比 (a s) / (a s))、蒙特卡洛积分方差缩减;面试常考“权重公式、方差条件、最优提议”。 解决的问题: 不生成目标样本也能算期望,且一份 q 的样本可同时服务多个目标分布(off-policy 复用);理论最优提议 q^*(x) p(x) |f(x)| 使 fw 常数、方差为 0,但它的归一化常数未知、仍需从 p|f| 采样,实践中改用厚尾提议,并监控有效样本量 ESS = 1 / _i w_i^2 防止权重退化。

核心要点

  • 推导 E_p[f] = E_q[f w] 与权重 w = p/q,为什么样本均值估计无偏?
  • 重要性采样的方差公式 Var_q[f w] 是什么?为何 q 与 p 失配时方差爆炸?
  • 最优提议分布是什么?为什么它把方差降到 0?实际中为何不能直接用?
  • 有效样本量 ESS = 1/ w_i^2 如何定义?它衡量什么?
  • 重要性采样与拒绝采样的区别?(算期望 vs 生成样本;权重加权 vs 0/1 接受)