Download presentation
Presentation is loading. Please wait.
1
Using random numbers Simulation: accounts for uncertainty: biology (large number of individuals), physics (large number of particles, quantum mechanics), human behavior, etc. Simulation: accounts for uncertainty: biology (large number of individuals), physics (large number of particles, quantum mechanics), human behavior, etc. Testing (large number of cases) Testing (large number of cases) Monte Carlo evaluation Monte Carlo evaluation Run experiments with humans Run experiments with humans
2
“Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin.” “Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin.” --- John von Neumann (1951) --- John von Neumann (1951)
3
What did von Neumann mean? Distinguish between “random” and “pseudorandom” Distinguish between “random” and “pseudorandom” Big advantage of pseudorandom: repeatability Big advantage of pseudorandom: repeatability Big disadvantage: not really random Big disadvantage: not really random
4
Linear Congruential Generator Most common and popular --- simple, fast, pretty good most of the time Most common and popular --- simple, fast, pretty good most of the time
5
Choosing good a, c, M [Tez95] gives nec. And suff. Conditions for LCG to have maximal period, M [Tez95] gives nec. And suff. Conditions for LCG to have maximal period, M This means we get all the integers in This means we get all the integers in {0, 1, …, (M-1)} in some order before repetition, then periodic {0, 1, …, (M-1)} in some order before repetition, then periodic But there are dangers lurking, more later But there are dangers lurking, more later
6
Using RNGs Choose an integer i between 1 and N randomly Choose an integer i between 1 and N randomly Choose from a discrete probability distribution; example: p(heads) = 0.4, p(tails) = 0.6 Choose from a discrete probability distribution; example: p(heads) = 0.4, p(tails) = 0.6 Pick a random point in 2-D: square, circle Pick a random point in 2-D: square, circle Shuffle a deck of cards Shuffle a deck of cards
7
“Random number generation is too important to be left to chance.” “Random number generation is too important to be left to chance.” --- Robert R. Coveyou (1969) --- Robert R. Coveyou (1969)
8
Danger and Caveats M, typically MAXINT, too small. For example, if M, typically MAXINT, too small. For example, if In a million calls the sequence will be repeated about 30 times! In a million calls the sequence will be repeated about 30 times! Don’t use low-order bits! Don’t use low-order bits! Points tend to be serially correlated Points tend to be serially correlated
9
“Random numbers fall mainly in the planes.” --- George Marsaglia (1968) “Random numbers fall mainly in the planes.” --- George Marsaglia (1968) “Every random number generator will fail in at least one application.” --- Donald Knuth (1969) “Every random number generator will fail in at least one application.” --- Donald Knuth (1969)
10
Quick summary of some probability theory Discrete vs. continuous Discrete vs. continuous Probability density function f (pdf) Probability density function f (pdf) Cumulative distribution function F (cdf) Cumulative distribution function F (cdf)
11
Generating other distributions Generate uniformly distributed x Generate uniformly distributed x Then compute y = g(x), where g( ) is monotically increasing and differentiable Then compute y = g(x), where g( ) is monotically increasing and differentiable Then pdf of y is Then pdf of y is
12
Important example Exponential distribution Exponential distribution
13
Generating a Gaussian: Box-Muller method Generate Generate Then Then are independent, Gaussian, zero mean, variance 1 are independent, Gaussian, zero mean, variance 1
14
Neave effect Tails of Box-Muller may be bad Tails of Box-Muller may be bad H. R. Neave, “On using the Box-Muller transformation with multiplicative congruential pseudorandom number generators,” Applied Statistics, 22, 92-97, 1973. H. R. Neave, “On using the Box-Muller transformation with multiplicative congruential pseudorandom number generators,” Applied Statistics, 22, 92-97, 1973.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.