Basics of Monte Carlo Simulation: Condensed From A Presentation by M. Asai
Basics of Monte Carlo Simulation: Condensed From A Presentation by M. Asai
Simulation
condensed from a presentation
by M. Asai
Dennis Wright
Geant4 Tutorial at Sao Paulo
4 February 2019
Contents
• Historical review of Monte Carlo methods
• Boosting simulation
– variance reduction techniques
x Length of the
Distance
q needle = L
between
lines = D
• Random points : N
• Random points inside circle : Nc
p ~ 4 Nc / N
• A PDF f (x) is a density function, i.e., it specifies the probability per unit of x,
so that f (x) has units that are the inverse of the units of x
• Rather, f (x)dx is the probability that a random sample xi will assume a value
within x and x+dx
– often, this is stated in the form
f (x) = Prob{ x < xi < x+dx }
where f (x) is a PDF over the interval [a, b], is called the Cumulative
Distribution Function (CDF) of f.
• A CDF has the following properties:
1) F(a) = 0., F(b) = 1.
2) F(x) is monotonically increasing, as f(x) is always non-negative
• When yi > f(xi) the point lies above the curve for
f(x), and xi is rejected; when yi ≤ f(xi) the points
lies on or below the curve, and xi is accepted
• The variance s2 describes the spread of the random variable x from the mean
and defined as
Note: 1
where xi are suitably sampled from PDF f (x), one can expect
• the probability that the particle decays at time t is given by the cumulative distribution
function F which is itself is a random variable with uniform probability on [0,1]
• Thus, having a uniformly distributed random number r on [0,1], one can sample the value t
with the probability density function f(t).
q = p x r1, f = 2p x r2 q = cos-1(r1), f = 2p x r2
0 < r 1, r 2 < 1 0 < r 1, r 2 < 1
dW = sinq dq df
Radiation Simulation and Monte Carlo Method - M. Asai (SLAC) 22
Compton scattering (1)
• Compton scattering
e- g à e- g
• Distance traveled before Compton scattering, l, is a
random value
Cross section per atom : s(E,z) f
Number of atoms per volume : n = r NA / A
r : density, NA : Avogadro number, A : atomic mass
Cross section per volume : h(E, r) = n s
• h is the probability of Compton interaction per unit length. l(E, r) = h-1 is the mean free
path associated with the Compton scattering process.
• The probability density function f(l)
• With a uniformly distributing random number r on [0,1), One can sample the distance l.
l = -l ln( r ) 0<r<1
l1 l2 l3
l1 l2 l3
nl = -ln( r ) 0<r<1
nl = nl - li / li
f
hn : energy of incident photon
hn0 : energy of scattered photon
E : energy of recoil electron
me : rest mass of electron
c : speed of light
• For unpolarized photon, the Klein-Nishina angular distribution function per steradian of
solid angle W
x Length of the
q
Distance needle = L
between
lines = D
the IC chip
• Stated in words:
The CLT tells us that the asymptotic distribution of is a unit
where xi are suitably sampled from PDF f (x), one can expect
• Because both and must always be positive, the sample variance s2 can be
reduced by reducing their difference.
• Thus, the various variance reduction techniques are directed, ultimately, to
minimizing the quantity − .
– Note that, in principle, it is possible to attain zero variance, if = , which
occurs if every history yields the sample mean. But this is not very likely.
However, it is possible to reduce substantially the variance among histories
by introducing various biases into a Monte Carlo calculation.
x
biased
pdf(x) analog-pdf(x)
w(x) = ------------------
biased-pdf(x)
x
• The weight for a given value x, is the ratio of the analog over the
biased distribution values at x.
Geant4 Biasing 38
Weight window
• Monitor the weight of each particle
• If the weight becomes too high:
– it makes too large a contribution to the estimate and slows the
convergence à make two particles with half the weight
• If the weight becomes too low:
– it does not contribute much to the estimate and thus wastes CPU à kill
the particle with 50% probability, the rest of the time double its weight
weight
split
upper limit
window
weight
lower limit
Russian Roulette
Figure of Merit
measure of calculation
(statistical) precision. (T : time spent for the simulation)
R > 0.5 : not trustable usually constant except for very small statistics
0.1 < R < 0.5 : questionable Good measure of the efficiency of Monte Carlo method
R < 0.1 : reasonable (the higher FOM is the better)
- In the Buffon’s needle case, FOM for z << 1 is 1000
times better than FOM for z > 1.