MATH ML Learning Lab
P02
P02 · 20–30 min

重要性采样与方差控制Importance Sampling & Variance Control

从另一种分布抽样时,怎样加权才能估计目标平均值?How can samples from another distribution be weighted to estimate a target expectation?

前置知识:Prerequisites: B20:抽样误差与蒙特卡洛估计。B20: sampling error and Monte Carlo estimation.

复习前置:Review prerequisites: B20 · 抽样误差与蒙特卡洛估计Sampling Error & Monte Carlo Estimation

学完后你能:After this lesson you can: 计算重要性权重,并区分缺失覆盖与高方差。Calculate importance weights and distinguish missing coverage from high variance.

动手观察Explore

改变提议分布中稀有类别的概率,抽样并比较加权估计与理论方差;检查缺失覆盖。Change the proposal probability of a rare category, sample and compare the weighted estimate and theoretical variance; inspect missing coverage.

从观察到解释From observation to explanation

先算一个有限例子Start with a finite example

目标分布有稀有与常见两类,稀有概率为 0.1;令稀有类 f=10、常见类 f=0,目标期望为 1。The target distribution has rare and common categories, with rare probability 0.1. Let f=10 for rare and f=0 for common; the target expectation is 1.

改变抽样分布Change the sampling distribution

若提议分布以 q 的概率抽到稀有类,每个稀有样本的加权值为 (0.1/q)×10=1/q,常见样本贡献 0。把加权值取平均,期望仍为 1。If the proposal draws the rare category with probability q, each rare sample contributes (0.1/q)×10=1/q and common samples contribute 0. Their average still has expectation 1.

覆盖与方差是不同问题Coverage and variance are different issues

本例单次加权值的方差为 1/q−1;q 太小时,少量极大权重可能造成高方差。q=0 时稀有类别缺失,无法估计其非零贡献;完整重加权通常要求提议分布覆盖目标分布的支持。Here the variance of one weighted value is 1/q−1; very small q produces rare, large weights and high variance. At q=0 the rare category is missing, so its nonzero contribution cannot be estimated. General reweighting typically requires proposal support to cover target support.

公式与符号Formula and symbols

p 是目标分布,q 是提议分布,f 是要平均的数值;p(X)/q(X) 是权重。相关非零项必须由 q 覆盖,且期望要存在。p is the target distribution, q the proposal, and f the quantity to average. p(X)/q(X) is the weight. The proposal must cover relevant nonzero terms and the expectation must exist.

留意这个区别Watch for this

覆盖不足与高方差不同;裁剪权重通常引入偏差,不能免费消除方差。Missing coverage and high variance are distinct. Clipping weights generally introduces bias and does not eliminate variance for free.

继续探索Explore further

课后练习

检验你的理解