Computational Physics - Department of Physics

(Axel Boer) #1

11.4 Improved Monte Carlo Integration 369


and
y=



−2 ln( 1 −x′)sin(θ),

withx′∈[ 0 , 1 ]andθ∈ 2 π[ 0 , 1 ].
A function which yields such random numbers for the normal distribution would include
statements like


idum=-1;
radius=sqrt(-2ln(1.-ran0(idum)));
theta=2
piran0(idum);
x=radius
cos(theta);
y=radius*sin(theta);


11.4.2Importance Sampling


With the aid of the above variable transformations we address now one of the most widely
used approaches to Monte Carlo integration, namely importance sampling.
Let us assume thatp(y)is a PDF whose behavior resembles that of a functionFdefined in
a certain interval[a,b]. The normalization condition is


∫b
a

p(y)dy= 1.

We can rewrite our integral as


I=

∫b
a

F(y)dy=

∫b
a

p(y)
F(y)
p(y)
dy.

This integral resembles our discussion on the evaluation ofthe energy for a quantum me-
chanical system in Eq. (11.22).
Since random numbers are generated for the uniform distributionp(x)withx∈[ 0 , 1 ], we
need to perform a change of variablesx→ythrough


x(y) =

∫y
a

p(y′)dy′,

where we used
p(x)dx=dx=p(y)dy.


If we can invertx(y), we findy(x)as well.
With this change of variables we can express the integral of Eq. (11.4.2) as


I=

∫b
a

p(y)F(y)
p(y)
dy=

∫b ̃
a ̃

F(y(x))
p(y(x))
dx,

meaning that a Monte Carlo evaluation of the above integral gives


∫b ̃
a ̃

F(y(x))
p(y(x))
dx=

1

N

N

i= 1

F(y(xi))
p(y(xi))

.

Note the well the change in integration limits fromaandbtoa ̃and ̃b. The advantage of such
a change of variables in casep(y)follows closelyFis that the integrand becomes smooth and

Free download pdf