Home /permanent

Importance Sampling

Importance Sampling is a technique for estimating an expectation under a target distribution p(x)p(x) that is hard to sample from, by drawing samples from an easier proposal distribution q(x)q(x) and weighting each sample by p(x)q(x)\frac{p(x)}{q(x)}:

Ep[f(x)]=Eq[f(x)p(x)q(x)]≈1N∑i=1Nf(xi)p(xi)q(xi),xi∼q \mathbb{E}_{p}[f(x)] = \mathbb{E}_{q}\left[f(x)\frac{p(x)}{q(x)}\right] \approx \frac{1}{N}\sum_{i=1}^{N} f(x_i)\frac{p(x_i)}{q(x_i)}, \quad x_i \sim q

It works well when qq is close to pp. When they're very different, especially in high dimensions, a few samples end up with huge weights and the estimate has high variance. Annealed Importance Sampling addresses this by moving gradually from qq to pp through a sequence of intermediate distributions.