I want to solve the integral

$$I =\int_{0}^{3} \frac{\exp(-s)}{1+\frac {1}{s}} \text{d}s $$

using importance sampling.

I'm unsure as to how implement it.

I have sampled random variables from an exponential distribution.

$$ x = -\log(1-U)\ \text{with}\ U \sim \mathcal{U}(0,1) $$

Am I right in thinking that

$$ \hat{I} = \frac{1}{N}\sum f(x)/g(x) $$

is a proper importance sampling approximation, where $$f(s)=\frac{\exp(-s)}{1+\frac {1}{s}}$$

and $g$ is the pdf of the standard exponential distribution.


1 Answer 1


Pretty close. Remember that exponentials have support on the positive reals.

$$ \frac{1}{N}\sum_i f(x_i)/g(x_i) \to E_g[f(x)/g(x)] = \int_0^{\infty}f(x)/g(x) g(x)dx = \int_0^{\infty}f(x) dx \neq \int_0^3 f(x) dx. $$

Instead try computing $\frac{1}{N}\sum_i f(x_i)/g(x_i)1(0 < x_i < 3)$.

  • $\begingroup$ Ok great, that makes sense. $\endgroup$ Commented Dec 3, 2017 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.