Monte Carlo Integration - Importance Sampling

trelek2
Messages
86
Reaction score
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:
<f>=\int_{0}^{1}f(x)dx= \int_{0}^{1}p(x) \frac{f(x)}{p(x)}dx
So I thought that the implementation is the following
<f>= \frac{1}{N} \sum_{i=1}^{N} \frac{f(x _{i} )}{p(x _{i} )}
and the estimated error will be given by:
( \frac{1}{N} \sum_{i=1}^{N} \frac{f(x _{i} )*(f(x _{i} )}{p(x _{i} )}) -<f> ^{2}

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!
 
Mathematics news on Phys.org
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?
The simplest method is simply to scale (assuming a and b finite) a<x<b.
Let y = (x-a)/(b-a)

And how are these formulas modified when dealing with a multidimentional integral. If my understanding of importance sampling is already wrong please correct me!

Your understanding is correct as far as it goes. For multidimensional integrals, it is easier to do the integration one dimension at a time.
 
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Fermat's Last Theorem has long been one of the most famous mathematical problems, and is now one of the most famous theorems. It simply states that the equation $$ a^n+b^n=c^n $$ has no solutions with positive integers if ##n>2.## It was named after Pierre de Fermat (1607-1665). The problem itself stems from the book Arithmetica by Diophantus of Alexandria. It gained popularity because Fermat noted in his copy "Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et...
I'm interested to know whether the equation $$1 = 2 - \frac{1}{2 - \frac{1}{2 - \cdots}}$$ is true or not. It can be shown easily that if the continued fraction converges, it cannot converge to anything else than 1. It seems that if the continued fraction converges, the convergence is very slow. The apparent slowness of the convergence makes it difficult to estimate the presence of true convergence numerically. At the moment I don't know whether this converges or not.
Back
Top