Importance sampling
Importance sampling is a method to study one distribution while sampling from another. Essentially, it performs biased sampling to generate pseudorandom numbers more sparingly. For example, instead of taking the points from a uniform distribution, the points are chosen from a distribution that concentrates the points in the region of interest of the function being integrated, thus focusing on the most important samples. The formula for the integrand can be written as follows:
To perform importance sampling, we need to do the following:
Generate n random numbers (x1, x2, …, xi) approximately g(x)
- Introduce weights f(x)/g(x) and estimate the integrand as , where x is approximately equal to g
Compute the Monte Carlo estimate for the integrand as follows:
For example, let's estimate the integral using this method.
Using the truncated exponential sampling distribution (λ = 0.65) truncated at T = 1, we can write:
Hence, becomes and the integral can be estimated as .
Now implement...