# Evaluate an integral using importance sampling

Estimate $$\int^{1}_{0}e^{x} dx$$ using importance sampling. Should I use beta distribution as proposal distribution and uniform distribution as target ?

• please add the self-study tag and explain why using one versus the other is an issue. Nov 24, 2019 at 7:54

As the range of the integral is $$(0,1)$$, it is better to take an importance density restricted to $$(0,1)$$ like the Uniform $$\mathcal U(0,1)$$ or a Beta $$\mathcal Be(a,b)$$, rather than an importance function with a larger support like Exponential or Normal. Intuitively, including a random number of zeroes in the Monte Carlo average is both a waste of computer time and an unnecessary source of randomness! Here is a comparison of the four (for 10³ simulations, replicated 10² times):
that seems to put a black mark on the Beta. However, the choice of a Beta $$\mathcal B(2,1)$$ is quite poor as $$\frac{\exp(-x)}{x^{2-1}(1-x)^{1-1}}$$ has infinite variance. Using instead a Beta $$\mathcal B(1/2,1)$$ leads to much better performances:
As a final experiment, restricting the simulations of both Exponential and Normal variates to $$(0,1)$$ leads to an obvious improvement
with a zero variance in the case of the truncated Exponential importance function, since it uses the probability of being between $$0$$ and $$1$$, which is the value of the integral itself.
This integral is easy using direct monte carlo integration, however if you want to use importance sampling, you can choose the target distribution as $$f(x)=e^x$$, i.e. harder to sample than uniform. And $$h(x)=\Pi(x)$$, i.e. $$1$$ within $$[0,1]$$ and zero otherwise. Choose normal ($$g(x)=\frac{1}{\sqrt{2\pi}}e^{-x^2/2})$$ or beta if you want, sample from it and take the mean, i.e. $$I\approx \frac{1}{N}\sum_{x \sim g(x)} \frac{f(x)h(x)}{g(x)}$$