Monte Carlo Simulation Technique: Random Number Generators
Monte Carlo Simulation Technique: Random Number Generators
Monte Carlo Simulation Technique: Random Number Generators
1
26-10-2020
2
26-10-2020
Arithmetic generators
• Linear congruential generators (LCGs)
– Introduced by Lehmer (1951)
– A sequence of integers Z1, Z2, … are defined
by the recursive formula:
• Zi=(aZi-1+c)(mod m)
• Where m is the modulus, a is a multiplier, c is an
increment, and all three parameters are positive
integers.
• =(aZi-1+c)(mod m) means the whole remainder of
(aZi-1+c) after dividing it by m
• 15 mod 4=3 & 17 mod 5=2
• Zi is an integer and varies between 0 and m-1.
3
26-10-2020
4
26-10-2020
Periodicity
• If Z0=3 produces Z1=746, then whenever
Zi-1=3, then Zi=746.
– This property is called periodicity
– {83,83,83,…} – periodicity=1
– {94,4832,325,94,4832,325,..} – Periodicity=3
– Undesirable and common random-number
generators suffer from this.
• Generate random numbers with the
following values: Z0=21, a=25, c=55, and
m=96.
Periodicity
• Generate random numbers with the
following values: Z0=21, a=25, c=55, and
m=96.
– 21,4,59,90,1, …
– Uniformly distributed random numbers
between 0 &1 [0,1):
4/96=0.042, 59/96=0.614, 90/96=0.9375,
• Maximum periodicity of LCG is m, and will
occur only if a,c, and m are selected
carefully. This is called full periodicity.
5
26-10-2020
Periodicity of a generator
• A generator has full period if its period is
m.
• A generator which is full period will
produce exactly one of each possible
values, {0,1, …., m-1), in each cycle.
• If the generator is good, all of these
possible values will appear to occur in
random order.
6
26-10-2020
Example
• Is Zi=(25Zi-1+55) (mod 96) is a full period
generator?
7
26-10-2020
Example
• Generate 10 uniformly distributed random
numbers between 20 and 50.
8
26-10-2020
9
26-10-2020
Inverse Transformation
FU(u) FX(x)
1.0 1.0
0.5 0.5
0.0 0.0
U fU(u) fX(x) X
U 1 ui 0 xi X
Example – Normal RV
• Generate 2 random variates for bearing
capacity following normal distribution with
mean 500 kPa and standard deviation 5
kPa, using inverse transformation
technique.
10
26-10-2020
Example – Lognormal RV
• Generate 2 random variates for bearing
capacity following lognormal distribution
with mean 500 kPa and standard deviation
5 kPa, using inverse transformation
technique.
11
26-10-2020
Box-Muller (1958)
• If X is a normally distributed with mean mX
and standard deviation sX, then
realizations of X can be generated as:
1. Generate u1~U(0,1) and u2 ~U(0,1)
2. Form g1=sqrt(-2lnu1) cos(2pu2) and
g2= sqrt(-2lnu1) sin(2pu2)
3. Form x1=mX+sXg1 and x2= mX+sXg2
This method generates realizations of X1
and X2, which are independent normal
random variates.
Example
• Generate two random variates following
normal distribution with mean 12 and
standard deviation 4, using the following
two uniformly distributed random numbers
between 0 and 1. Use Box-Muller method.
• u1=0.89362
• u2=0.42681
12
26-10-2020
Example
To estimate the settlement due to consolidation of a
homogeneous saturated soil deposit, the information on the
coefficient of consolidation, cv is a very important. It can be
calculated as:
𝑘
𝑐𝑣 =
𝑚𝑣 𝛾𝑤
Where, k is the hydraulic conductivity, mv is the coefficient
of volume compressibility, and gw is the unit weight of water.
Assume k and mv are statistically independent lognormal
random variables with means of 1.3 x 10-7 m/min and
0.0011 m2/kN, respectively. Both have coefficients of
variation of 10%. Using the above data, estimate P(cv>1.2 x
10-5 m2/min).
13