# Difference between revisions of "importance Sampling June 2 2009"

In $I = \displaystyle\int h(x)f(x)\,dx$, Monte Carlo simulation can be used only if it easy to sample from f(x). Otherwise, another method must be applied. If sampling from f(x) is difficult but there exists a probability distribution function g(x) which is easy to sample from, then $I$ can be written as

$I = \displaystyle\int h(x)f(x)\,dx$
$= \displaystyle\int \frac{h(x)f(x)}{g(x)}g(x)\,dx$
$= \displaystyle E_g(w(x)) \rightarrow$the expectation of w(x) with respect to g(x)
$= \frac{\displaystyle\sum_{i=1}^{N} w(x_i)}{N}$ where $\displaystyle w(x) = \frac{h(x)f(x)}{g(x)}$

Process

1. Choose $\displaystyle g(x)$ such that it's easy to sample from.
2. Compute $\displaystyle w(x)=\frac{h(x)f(x)}{g(x)}$
3. $\displaystyle \hat{I} = \frac{\displaystyle\sum_{i=1}^{N} w(x_i)}{N}$

"Weighted" average

The term "importance sampling" is used to describe this method because a higher 'importance' or 'weighting' is given to the values sampled from $\displaystyle g(x)$ that are closer to $\displaystyle f(x)$, the original distribution we would ideally like to sample from (but cannot because it is too difficult).
$\displaystyle I = \int\frac{h(x)f(x)}{g(x)}g(x)\,dx$
$=\displaystyle \int \frac{f(x)}{g(x)}h(x)g(x)\,dx$
$=\displaystyle \int \frac{f(x)}{g(x)}E_g(h(x))\,dx$ which is the same thing as saying that we are applying a regular Monte Carlo Simulation method to $\displaystyle\int h(x)g(x)\,dx$, taking each result from this process and weighting the more accurate ones (i.e. the ones for which $\displaystyle \frac{f(x)}{g(x)}$ is high) higher.

One can view $\frac{f(x)}{g(x)}\ = B(x)$ as a weight.

Then $\displaystyle \hat{I} = \frac{\displaystyle\sum_{i=1}^{N} w(x_i)}{N} = \frac{\displaystyle\sum_{i=1}^{N} B(x_i)*h(x_i)}{N}$

i.e. we are computing a weighted sum of $h(x_i)$ instead of a sum.