Chapter 4 Monte Carlo Methods and Simulation. Monte Carlo Methods.
Modeling and Simulation Dr. X. Topics Random Numbers Monte Carlo Simulation.
-
Upload
darcy-casey -
Category
Documents
-
view
225 -
download
2
Transcript of Modeling and Simulation Dr. X. Topics Random Numbers Monte Carlo Simulation.
John von Neumann
• Quantum theory• Logic• Game theory• Economics• Theory and applications of Computer Science• Monte Carlo Simulation– WWII– How system neutrons would behave
Multiplicative linear congruential generator
• Lehmer• Generate 10 random numbers– r0=10
– rn = (7rn-1+1)mod11, n>0
• What is r0?• How do we know it will only generate 10
numbers?
Monte Carlo Algorithm
Monte Carlo algorithm to estimate area between x-axis and f from SMALLEST_X to LARGEST_XMAX_Y number greater than or equal to all f(x) in the intervalNUMDARTS number of darts to be thrownNumHitsBelow 0Do the following NUMDARTS times:
randomX random number between SMALLEST_X and LARGEST_XrandomY random number between 0 and MAX_Yif(randomY < f(randomX))
increment NumHitsBelow by 1AreaOfRectangle (LARGEST_X – SMALLEST_X) *(MAX_Y)
EstimatedArea (AreaOfRectangle)*(NumHitsBelow)/ NUMDARTS
Random Numbers from Distributions
• Distribution: description of the portion of times each possible outcome or each possible range of outcomes occurs on average
• Discrete • Continuous
Generate random numbers from discrete distribution
Generate rand, a uniform random floating point number [0, 1)If rand < p1, then return e1
else if rand < p1+ p2, then return e2
…else if rand < p1+ p2+…+pn-1, then return en-1
else return en
Generate random numbers from continuous distribution
Reverse the distribution– Normal – Box Muller
x = b * sin(a) + μ and x = b * cos(a) + μ where:
a = random number between [0, 2π)rand = uniform random number between [0,1)b = σ
– Exponentialx = 1/a * log(rand) where:rand = uniform random number between [0,1)