UNIFORM RANDOM NUMBER GENERATION Chapter 7 first half
UNIFORM RANDOM NUMBER GENERATION Chapter 7 (first half) n The goal is to generate a sequence of n Uniformly distributed n Independent n X 1, X 2, …. IID Unif[0, 1] These are the basis of generating all random variates in simulations
UNIFORM [0, 1] f(x) 1 x 0 1
EARLY METHODS USED PHYSICAL PHENOMENON n Spinning disks with digits on them n Dice (generate on 1/6, 2/6, …, 1) n Picking people out of the phone book n n Picking the nth (n = 1200, 1201, …) digit in p Gamma ray photon counting
SEQUENCIAL COMPUTER-BASED METHODS n Antique Mid-Square Method (Von Neumann) n Z 0 is a four-digit number n Z 1 = middle four digits of Z 02 n Z 2 = middle four digits of Z 1 n Ui = Zi/10000
SAMPLE MID-SQUARE i Zi 0 7182 1 5811 2 7677 3 9363 4 6657 Zi^2 515811 24 Ui 337677 21 0. 5811 589363 29 0. 7677 876657 69 0. 9363 443156 49 0. 6657
MID-SQUARE PROPERTIES n n n Once you know a Z, you can accurately predict the entire future sequence (not really random) If a Z ever repeats, the whole sequence starts over Only generate 9999 numbers (not dense in [0, 1] Turns out, we LIKE some of these properties for computer simulations (Repeatability enables debugging)
DESIRABLE PROPERTIES n Appear Unif[0, 1] n Fast algorithm n Reproducible stream n n Debugging n Contrast in comparison (Variance Reduction) Lots of numbers before a repeat
LINEAR CONGRUENTIAL GENERATOR (Lehmer, 1954) n Z 0 is the SEED n m is the MODULUS n a is the MULTIPLIER n c is the INCREMENT (forget this one)
PROPERTIES n Can generate at most m-1 samples before repeat n n n Length of non-repeating sequence called the PERIOD of the generator If you get m-1, you have a full cycle generator Divides [0, 1] into m equal slices
unif. xls n n observe the basic functions of the seed, multiplier, and modulus experiment with multipliers for n m = 17 n m = 16
HISTORY n n n Necessary for full cycle n a and m relatively prime n q (prime) divides m and a-1 m = 2, 147, 483, 648 = 231 -1 is everybody’s favorite 32 -bit generator (SIMAN, SIMSCRIPT, GPSS/H, Arena) Fishman, G. S. (1972). An Exhaustive Study of Multipliers for Modulus 231 -1, RAND Technical Series. n a = 630, 360, 647
HISTORICAL COMPETITION FOR LINEAR CONGRUENTIAL GENERATORS n add or multiply some combination of variates from the stream’s recent history
WHAT IS GOOD n Full, Long Cycle n Seemingly Independent n We can test this, but our simple tests stink
2 c Test for U[0, 1] n U 1, U 2, . . . Un a sequence of U[0, 1] samples n Let us divide [0, 1] into k equally-sized intervals n Let oi = observations in [(i-1)/k, i/k] n ei = n/k is the expected number of Ui’s that fall in [(i-1)/k, i/k] for each i
TESTING n n cn-12 follows the Chi-Squared distribution with n 1 degrees of freedom DUMB TEST n n n any full-cycle generator is exactly AOK expand to two or more dimensions using n- tuples (Ui, Ui+1, . . . , Ui+n) maybe a picture would be better?
- Slides: 15