Professional Documents
Culture Documents
PER LÖTSTEDT
(excerpt adopted for Beräkningsvetenskap I)
1
Div of Scientific Computing, Dept of Information Technology
Uppsala University, SE-75105 Uppsala, Sweden
email: perl@it.uu.se
1 Introduction
Monte Carlo methods use sequences of random numbers to solve problems in
e.g. mathematics, physics and chemistry. The reasons why random numbers are
involved are
Xn+1 = Xn + ∆Xn .
If the displacement ∆Xn is chosen randomly, then we have a random walk process.
In the second example there is no known way of solving the problem except
for simulating the behavior using randomness. In a biological system, molecules
react with each other, collide and move in space. We are interested in the large
scale behavior of the system and not all the details. It is sometimes very difficult
to derive a deterministic model such as a differential equation for the large scale.
A solution is then to simulate all the reactions, collisions and movements in
the system with a limited number of molecules and draw conclusions from the
simulations.
1
A problem that can be solved in principle with a deterministic method is
instead solved with a stochastic algorithm in the last example. The reason is that
the deterministic algorithm is so computationally complicated that the stochastic
one is preferred. The computational work grows too quickly for the deterministic
method when the dimension of the integral increases but it grows much slower
for the stochastic algorithm.
A discussion of Monte Carlo methods is found in [1, 2, 3].
2
Values that have been used in the past are a = 216 + 3, b = 0, and M = 231 , see
[4]. However, this choice of values has deficiencies, see [5]. If we need a uniform
distribution in the interval [c, d), then after a transformation vi = c + (d − c)ui ∼
U(c, d). MATLAB generates a square matrix of dimension n with uniformly
distributed elements in [0, 1) with rand(n).
1 X
N
ξN = g(xi ) (3)
N i=1
1 X
N
ξN = (d − c) g(xi ),
N i=1
3
The error in the approximation is
²N = I0 − ξN .
The central limit theorem in statistics tells us that the error ²N is a stochastic
variable such that
σ
²N ≈ √ η, (4)
N
where η is normally distributed N (0, 1). The variance of g is here denoted by σ 2
and is defined by
Z 1
2
σ = (g(x) − I0 )2 dx. (5)
0
The conclusion from (4) is that the error ²N with N terms in the approximation
ξN in (3) of I0 in (2) decays with the speed N −1/2 when N increases.
If we instead compute I0 with the trapezoidal method, then with a constant
step size h and N = 1/h, the formula is
X
N −1
I0 ≈ 0.5(g(0) + g(1)) + g(ih). (6)
i=1
4
The Monte Carlo approximation of ID is
1 X
N
ID ≈ g(xi ).
N i=1
g(x)
g max
0 1 x
Yi ≤ g(Xi ).
Then the area A under g(x) and the area Amax under gmax satisfy
A M
≈ ,
Amax N
5
see Fig. 1. The integral I0 is then approximated by
M
I0 = A ≈ gmax .
N
The value of gmax above does not have to be the exact maximum of the func-
tion, but should be a value fairly near that.
References
[1] R. E. Caflish, Monte Carlo and quasi-Monte Carlo methods, Acta Nu-
merica, 1998, p. 1–49.
[5] R. Seydel, Tools for Computational Finance, 2nd ed., Springer, Berlin,
2004.