- #1
trelek2
- 88
- 0
Hi!
I'm trying to write an algorithm that performes Importance Sampling Monte Carlo integration.
I found some info about it, but I have trouble understanding how it actually can be implemented.
Let f(x) be the function we want to integrate and p(x) the non-uniform probability distribution function which is normalized and is in the same shape as f(x). p(x) returns values in the range of the interval we want to integrate. The monte carlo importance sampling formula is the following:
[tex] <f>=\int_{0}^{1}f(x)dx= \int_{0}^{1}p(x) \frac{f(x)}{p(x)}dx [/tex]
So I thought that the implementation is the following
[tex]<f>= \frac{1}{N} \sum_{i=1}^{N} \frac{f(x _{i} )}{p(x _{i} )} [/tex]
and the estimated error will be given by:
[tex] ( \frac{1}{N} \sum_{i=1}^{N} \frac{f(x _{i} )*(f(x _{i} )}{p(x _{i} )}) -<f> ^{2}[/tex]
The problem is that this works only for integrals in the range 0 to 1.
What should I do if I want to integrate over the range from a to b?
And how are these formulas modified when dealing with a multidimentional integral. If my understanding of importance sampling is already wrong please correct me!
I'm trying to write an algorithm that performes Importance Sampling Monte Carlo integration.
I found some info about it, but I have trouble understanding how it actually can be implemented.
Let f(x) be the function we want to integrate and p(x) the non-uniform probability distribution function which is normalized and is in the same shape as f(x). p(x) returns values in the range of the interval we want to integrate. The monte carlo importance sampling formula is the following:
[tex] <f>=\int_{0}^{1}f(x)dx= \int_{0}^{1}p(x) \frac{f(x)}{p(x)}dx [/tex]
So I thought that the implementation is the following
[tex]<f>= \frac{1}{N} \sum_{i=1}^{N} \frac{f(x _{i} )}{p(x _{i} )} [/tex]
and the estimated error will be given by:
[tex] ( \frac{1}{N} \sum_{i=1}^{N} \frac{f(x _{i} )*(f(x _{i} )}{p(x _{i} )}) -<f> ^{2}[/tex]
The problem is that this works only for integrals in the range 0 to 1.
What should I do if I want to integrate over the range from a to b?
And how are these formulas modified when dealing with a multidimentional integral. If my understanding of importance sampling is already wrong please correct me!