Download presentation
Presentation is loading. Please wait.
Published byCaroline Rogers Modified over 8 years ago
1
Module 9.2 Simulations
2
Computer simulation Having computer program imitate reality, in order to study situations and make decisions Applications?
3
Use simulations if Not feasible to do actual experiments System does not exist Cost of actual experiments prohibitive Money Time Danger Want to test alternatives
4
Monte Carlo simulation Probabilistic model involving element of chance Not deterministic but is probabilistic or stochastic Uses random number generator Each time a simulation is run, results can vary from those of other runs Disadvantages-simulation maybe expensive in time,money to develop -since it is impossible to test every alternatives, only provide goog solution not a best solution –because a sim. Is probabilistic involving an element of chance, should be careful of our conclusions-results maybe difficult to verify cause often don’t have real world data – can’t be sure we understand what simulation actually does
5
Multiplicative Linear Congruential Method-D.J.Lenmer 1949 random 0 = 10 (seed) random n = (7 * random n - 1 ) mod 11(modulus), for n > 0 (generating function) Generates? 10, 4, 6, 9, 8, 1, 7, 5, 2, 3
6
Multiplicative Linear Congruential Method random 0 = seed random n = (multiplier * random n – 1 +increment) mod modulus, for n > 0 Good randon number generator should give as long a sequence as possible, sequence appers random modulus often largest integer comp. can store, such as 2 31 - 1 = 2,147,483,647 One multiplier: 16,807, increment 0
7
Random floating point number For random number, rand, with 0.0 ≤ r and < 1.0 rand = random n /modulus Example r 0 = 10, r n = (7 * r n - 1 ) mod 11, for n > 0 Integers: 10, 4, 6, 9, 8, 1, 7, 5, 2, 3 Floating point: 10/11, 4/11, …, 3/11
8
Different ranges of random numbers How to obtain uniformly distributed integer or real random numbers in any range For 0 ≤ rand < 1, r = (max - min) rand + min Random floating point number min ≤ r < max Example: random floating point number between 20.0 and 26.3? 6.3rand + 20.0
9
Random integer min ≤ n ≤ max For 0 ≤ rand < 1 n = int( (max - min + 1) rand + min) Example: random integer between 20 and 26, inclusively? int(7rand + 20)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.