Skip to main content

5.8 Importance sampling

Source: Ideas from Computational Physics (Landau, Páez, Bordeianu), §5.8. Rewritten in original wording. Continues 5.7 Monte Carlo variance reduction. Labs: 5.8b Importance-sampling labs.

Reweight the measure​

Write the integral against a weight (density) ww that you choose, average f/wf/w under samples from ww, then draw those samples by rejection or inverse CDF. Walk I=⟨f/w⟩wI=\langle f/w\rangle_w, the flattening choice w∝fw\propto f, von Neumann’s accept test, and the w=2(1−x)w=2(1-x) map — pick the matching equation at each step.

Flatten f/wf/w​

Uniform sampling is the special case w=constw=\mathrm{const}. Importance sampling is the natural next step when you can sample from a peaked ww that matches the integrand’s shape.

von Neumann rejection sampling​

How do you draw x∼wx\sim w when ww is not a standard distribution? Enclose ww in a box of height w0≥w(x)w_0\ge w(x); the guide’s rejection step keeps points under the curve. Accepted abscissae are distributed according to ww. The acceptance rate is the area under ww over the box area.

Figure 5.7 — von Neumann rejection: throw under a box of height w_0; keep points that fall under w(x).

Accepted samples feed an importance estimate ⟨f/w⟩\langle f/w\rangle. When ww is harder to sample by inversion or rejection, Metropolis algorithms (Chapter 17) generate correlated draws from ww without needing a tight enclosing box — mentioned here only as the later generalization.

Inverse-CDF shortcut​

If the CDF of ww is invertible, you can skip rejection: draw u∼U[0,1)u\sim U[0,1) and set x=Fw−1(u)x=F_w^{-1}(u). Example on [0,1][0,1]: w(x)=2(1−x)w(x)=2(1-x) — the guide’s last step — after which you average e−x/w(x)e^{-x}/w(x).

Quiz

Importance sampling

1 / 3

Importance sampling writes I as…

Pick an answer to see if you are right.

Next: 5.8b Importance-sampling labs.