Importance sampling in R course notes and code.
Importance sampling a Monte Carlo method to speed up the convergence of the MC estimates.
We start by approximating an integral of interest, namely
with crude Monte Carlo estimation. We get the following result
Then we take another example to approximate the following integral
and we show that the convergence is more stable and achieved faster with importance sampling, as seen on this graph.
Enjoy the content.