376 11 Outline of the Monte Carlo Strategy
/**
*@return A random number from a particular Random Number Generator
*implemented in the subclasses.
**/
virtual doublesample()=0;
};
#inlineRandom::~Random(){}
#endif
11.7 Exercises.
11.1.Calculate the cumulative functionsP(x)for the binomial and the Poisson distributions
and their variances.
11.2.Make a program which computes random numbers according to the algorithm of
Marsaglia and Zaman, Eqs. (11.16) and (11.17). Compute the correlation functionCkand
compare with the auto-correlation function from the functionran 0.
11.3.Make a functionnormal_randomwhich computes random numbers for the normal distri-
bution based on random numbers generated from the functionran 0.
11.4.Make a functionexp_randomwhich computes random numbers for the exponential dis-
tributionp(y) =e−αybased on random numbers generated from the functionran 0.
11.5.1. Calculate the integral
I=
∫ 1
0
e−x
2
dx,
using brute force Monte Carlo withp(x) = 1 and importance sampling withp(x) =ae−xwhere
ais a constant.
- Calculate the integral
I=
∫π
0
1
x^2 +cos^2 (x)
dx,
withp(x) =ae−xwhereais a constant. Determine the value ofawhich minimizes the variance.
11.6.In this exercise we are going to simulate the radioactive decay of these nuclei using
sampling through random numbers. We assume that att= 0 we haveNX( 0 )nuclei of the
typeXwhich can decay radioactively. At a given timetwe are left withNX(t)nuclei. With a
transition rateωX, which is the probability that the system will make a transition to another
state during a time step of one second, we get the following differential equation
dNX(t) =−ωXNX(t)dt,
whose solution is
NX(t) =NX( 0 )e−ωXt,
and where the mean lifetime of the nucleusXis
τ=^1
ωX
.
If the nucleusXdecays toY, which can also decay, we get the following coupled equations
dNX(t)
dt =−ωXNX(t),