Chapter 2 - Random Number Generation
Chapter 2 - Random Number Generation
Generation
For applying the Monte Carlo method we need an enormous amount of random samples
from a specified distribution
➢ How to efficiently produces those?
➢ Needed: randomness (and unpredictability)
Comments
+ Absolutely unpredictable
- Not practical (time consuming, expensive, difficult to implement on computer)
- Not reproducible
• Reproducibility is important: comparability of methods and implementation, debugging,
variance reduction, etc.
• We need an algorithm that produces numbers that “appear random” (pass statical tests) →
pseudorandom numbers
Random Number Generators
Definition
A random number Generator (RGN) is a deterministic algorithm that produces sequences of
numbers that mimic randomness → “pseudorandom numbers”.
Remark
• RNG’s usually have to be initialized (important!!)
• RNG’s produce a finite sequence of pseudorandom numbers which is then repeated. The
length of this sequence, denoted by ℓ, is called the period length of the RNG, for example
Algorithm: LCG
• Set 𝑠𝑛 ∈ 0,1, … , 𝑚 − 1 such that
𝑠𝑛+1 = 𝑎 𝑠𝑛 + 𝑐 mod 𝑚, ∀𝑛 ≥1
where
➢ 𝑚 ∈ ℕ\ {0} is the modulus
➢ 𝑎 ∈ ℕ is the multiplier, 𝑎 < 𝑚
➢ 𝑐 ∈ ℕ is the increment, 𝑐 < 𝑚
➢ 𝑠0 ∈ ℕ is the seed (initial point), 𝑠0 < 𝑚
𝑠𝑛
• Numbers in 0,1 are obtained via 𝑢𝑛 =
𝑚
Disadvantages
• The period of a LCG is < 𝑚 (period is relatively small)
• LCG’s usually do not have good random properties → Correlation between the
random numbers
• Discrete distribution: 𝑃 𝑋 ≤ 𝑐𝑖 = 𝑝𝑖 , 𝑖 = 1, … , 𝑛
𝑖
𝑞0 = 0, 𝑞𝑖 = 𝑝𝑗 , 𝑖 = 1, … , 𝑛
𝑗=1
𝑋 = 𝑐𝑘 , with 𝑘 such that 𝑞𝑘−1 < 𝑈 ≤ 𝑞𝑘
Acceptance-rejection method (1)
• Some distributions are so complicated that the inversion of the cdf 𝐹 is too difficult
or only approximations exist → given the density, the acceptance-rejection method
can be much faster and even easier
• We want to generate samples from a random variable 𝑋 with density function 𝑓
• We can generate samples from a random variable 𝑌 with density function 𝑔
• There exists a constant 𝑀 with 𝑓 𝑥 ≤ 𝑀𝑔 𝑥 ∀ 𝑥