# Using random numbers Simulation: accounts for uncertainty: biology (large number of individuals), physics (large number of particles, quantum mechanics),

## Presentation on theme: "Using random numbers Simulation: accounts for uncertainty: biology (large number of individuals), physics (large number of particles, quantum mechanics),"— Presentation transcript:

Using random numbers Simulation: accounts for uncertainty: biology (large number of individuals), physics (large number of particles, quantum mechanics), human behavior, etc. Testing (large number of cases) Monte Carlo evaluation Run experiments with humans

“Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin.” --- John von Neumann (1951)

What did von Neumann mean? Distinguish between “random” and “pseudorandom” Big advantage of pseudorandom: repeatability Big disadvantage: not really random

Sources of “randomness” “Digital Chaos”: Deterministic, complicated. Examples: pseudorandom RNGs in code, cellular automata (http://en.wikipedia.org/wiki/Rule_30),http://en.wikipedia.org/wiki/Rule_30 digital slot machines. “Analog Chaos”: Unknown initial conditions. Examples: roulette wheel, dice, card shuffle, analog slot machines. “Truly random”: Quantum mechanics (the world works microscopically).

Linear Congruential Generator Most common and popular --- simple, fast, pretty good most of the time

Choosing good a, c, M [Tez95] gives nec. And suff. Conditions for LCG to have maximal period, M This means we get all the integers in {0, 1, …, (M-1)} in some order before repetition, then periodic But there are dangers lurking, more later

Using RNGs Choose an integer i between 1 and N randomly Choose from a discrete probability distribution; example: p(heads) = 0.4, p(tails) = 0.6 Pick a random point in 2-D: square, circle Shuffle a deck of cards

“Random number generation is too important to be left to chance.” --- Robert R. Coveyou (1969)

Danger and Caveats M, typically MAXINT, too small. For example, if In a million calls the sequence will be repeated about 30 times! Don’t use low-order bits! Points tend to be serially correlated

“Random numbers fall mainly in the planes.” --- George Marsaglia (1968) “Every random number generator will fail in at least one application.” --- Donald Knuth (1969)

Quick summary of some probability theory Discrete vs. continuous Probability density function f (pdf) Cumulative distribution function F (cdf)

Generating other distributions Generate uniformly distributed x Then compute y = g(x), where g( ) is monotically increasing and differentiable Then pdf of y is

Important example Exponential distribution

Generating a Gaussian: Box-Muller method Generate Then are independent, Gaussian, zero mean, variance 1

Neave effect 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.

Download ppt "Using random numbers Simulation: accounts for uncertainty: biology (large number of individuals), physics (large number of particles, quantum mechanics),"

Similar presentations