Interactive element. Adjust the sample distribution and the desired distribution via the dropdown menus, and observe how importance sampling attempts to approximate the desired distribution using the sample distribution. All samples are black, sample weight is represented as opacity.

Importance sampling

Importance sampling plays an important role in particle filters. In many situations, we may be interested in samples from a desired pdf q(x) but we might only have access to samples from a pdf p(x). Importance sampling allows us to approximate sampling Y ~ q(x) by drawing samples X from p(x), then correcting for the difference between the two distributions by assigning weights to the samples X. The desired samples Y are then approximated as:

Y = q(X) / p(X)X

Experiment with the element above. Observe which combinations of sample and desired distribution work well, and which don't.