Montecarlo Integration
Montecarlo Integration
50% of points
Computing Random
Numbers
• When using randomness in our algorithms,
we need to be careful that we are using it
correctly
• In particular, that we dont destroy
randomness or distribution properties of
our sequence when manipulating them
Estimating Areas Via
Monte Carlo
• The previous discussion leads to a method
for estimating the area / volume of an
arbitrarily shaped object
• We only need to be able to test whether
or not a point is inside the object
Estimating Areas Via
Monte Carlo
• Procedure: generate a uniformly distributed
random point in some enclosing rectangle of
area A and test whether it is inside or
outside the object
• After n trials, we have p of our points inside
our object. The estimated area is then
p*A/n
Estimating Areas Via
Monte Carlo
Estimating Areas Via
Monte Carlo
• Why do we need uniformly distributed
points in order to get a good estimate of the
area / volume?
Estimating Area Via
Monte Carlo
• We can use this to compute an estimate for
the value of π in a similar way as well
• 10,000 trials: 3.1144
100,000 trials: 3.1385
Estimating Integrals Via
Monte Carlo
• We can also use Monte Carlo simulation to
estimate the value of integrals
• ∫01 f(x) dx ≈ 1/N ∑ f(xi)
where we have N uniformly distributed
random points in [0, 1]
Estimating Integrals Via
Monte Carlo
• Note that this is only over integral bounds
from 0 to 1. In general, we have an integral
over a to b
• 1/
(b-a) ∫a
b f(x) dx ≈ 1/N ∑ f(xi)
• Moving the weight to the other side, we get:
∫ab f(x) dx ≈ (b-a)/N ∑ f(xi)
Estimating Integrals Via
Monte Carlo
• This can be directly extended to multiple
integrals: