Presentation is loading. Please wait.

Presentation is loading. Please wait.

UNIFORM RANDOM NUMBER GENERATION Chapter 7 (first half) The goal is to generate a sequence of The goal is to generate a sequence of Uniformly distributed.

Similar presentations


Presentation on theme: "UNIFORM RANDOM NUMBER GENERATION Chapter 7 (first half) The goal is to generate a sequence of The goal is to generate a sequence of Uniformly distributed."— Presentation transcript:

1 UNIFORM RANDOM NUMBER GENERATION Chapter 7 (first half) The goal is to generate a sequence of The goal is to generate a sequence of Uniformly distributed Uniformly distributed Independent Independent X 1, X 2, …. IID Unif[0, 1] X 1, X 2, …. IID Unif[0, 1] These are the basis of generating all random variates in simulations

2 UNIFORM [0,1] 0 1 1 f(x) x

3 EARLY METHODS USED PHYSICAL PHENOMENON Spinning disks with digits on them Spinning disks with digits on them Dice (generate on 1/6, 2/6, …, 1) Dice (generate on 1/6, 2/6, …, 1) Picking people out of the phone book Picking people out of the phone book Picking the nth (n = 1200, 1201, …) digit in  Picking the nth (n = 1200, 1201, …) digit in  Gamma ray photon counting Gamma ray photon counting

4 SEQUENCIAL COMPUTER-BASED METHODS Antique Mid-Square Method (Von Neumann) Antique Mid-Square Method (Von Neumann) Z 0 is a four-digit number Z 0 is a four-digit number Z 1 = middle four digits of Z 0 2 Z 1 = middle four digits of Z 0 2 Z 2 = middle four digits of Z 1 Z 2 = middle four digits of Z 1 U i = Z i /10000 U i = Z i /10000

5 SAMPLE MID-SQUARE iZiZi^2Ui 0718251581124 15811337677210.5811 27677589363290.7677 39363876657690.9363 46657443156490.6657 5315699603360.3156

6 MID-SQUARE PROPERTIES Once you know a Z, you can accurately predict the entire future sequence (not really random) 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 If a Z ever repeats, the whole sequence starts over Only generate 9999 numbers (not dense in [0, 1] Only generate 9999 numbers (not dense in [0, 1] Turns out, we LIKE some of these properties for computer simulations (Repeatability enables debugging)

7 DESIRABLE PROPERTIES Appear Unif[0, 1] Appear Unif[0, 1] Fast algorithm Fast algorithm Reproducible stream Reproducible stream Debugging Debugging Contrast in comparison (Variance Reduction) Contrast in comparison (Variance Reduction) Lots of numbers before a repeat Lots of numbers before a repeat

8 LINEAR CONGRUENTIAL GENERATOR (Lehmer, 1954) Z 0 is the SEED Z 0 is the SEED m is the MODULUS m is the MODULUS a is the MULTIPLIER a is the MULTIPLIER c is the INCREMENT (forget this one) c is the INCREMENT (forget this one)

9 PROPERTIES Can generate at most m-1 samples before repeat Can generate at most m-1 samples before repeat Length of non-repeating sequence called the PERIOD of the generator Length of non-repeating sequence called the PERIOD of the generator If you get m-1, you have a full cycle generator If you get m-1, you have a full cycle generator Divides [0, 1] into m equal slices Divides [0, 1] into m equal slices

10 unif.xls observe the basic functions of the seed, multiplier, and modulus observe the basic functions of the seed, multiplier, and modulus experiment with multipliers for experiment with multipliers for m = 17 m = 17 m = 16 m = 16

11 HISTORY Necessary for full cycle Necessary for full cycle a and m relatively prime a and m relatively prime q (prime) divides m and a-1 q (prime) divides m and a-1 m = 2,147,483,648 = 2 31 -1 is everybody’s favorite 32-bit generator (SIMAN, SIMSCRIPT, GPSS/H, Arena) m = 2,147,483,648 = 2 31 -1 is everybody’s favorite 32-bit generator (SIMAN, SIMSCRIPT, GPSS/H, Arena) Fishman, G. S. (1972). An Exhaustive Study of Multipliers for Modulus 2 31 -1, RAND Technical Series. Fishman, G. S. (1972). An Exhaustive Study of Multipliers for Modulus 2 31 -1, RAND Technical Series. a = 630,360,647 a = 630,360,647

12 HISTORICAL COMPETITION FOR LINEAR CONGRUENTIAL GENERATORS add or multiply some combination of variates from the stream’s recent history add or multiply some combination of variates from the stream’s recent history

13 WHAT IS GOOD Full, Long Cycle Full, Long Cycle Seemingly Independent Seemingly Independent We can test this, but our simple tests stink We can test this, but our simple tests stink

14  2 Test for U[0, 1] U 1, U 2,...U n a sequence of U[0, 1] samples U 1, U 2,...U n a sequence of U[0, 1] samples Let us divide [0, 1] into k equally-sized intervals Let us divide [0, 1] into k equally-sized intervals Let o i = observations in [(i-1)/k, i/k] Let o i = observations in [(i-1)/k, i/k] e i = n/k is the expected number of U i ’s that fall in [(i-1)/k, i/k] for each i e i = n/k is the expected number of U i ’s that fall in [(i-1)/k, i/k] for each i

15 TESTING  n  2 follows the Chi-Squared distribution with n- 1 degrees of freedom  n  2 follows the Chi-Squared distribution with n- 1 degrees of freedom DUMB TEST DUMB TEST any full-cycle generator is exactly AOK any full-cycle generator is exactly AOK expand to two or more dimensions using n- tuples (U i, U i+1,..., U i+n ) expand to two or more dimensions using n- tuples (U i, U i+1,..., U i+n ) maybe a picture would be better? maybe a picture would be better?


Download ppt "UNIFORM RANDOM NUMBER GENERATION Chapter 7 (first half) The goal is to generate a sequence of The goal is to generate a sequence of Uniformly distributed."

Similar presentations


Ads by Google