1 / 17

Random Number Generation

Random Number Generation. Random Number Generators. Without random numbers, we cannot do Stochastic Simulation Most computer languages have a subroutine, object or function generating random numbers (uniformly distributed)

Download Presentation

Random Number Generation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Random Number Generation

  2. Random Number Generators • Without random numbers, we cannot do Stochastic Simulation • Most computer languages have a subroutine, object or function generating random numbers (uniformly distributed) • Simulation languages provide more than that (you can get random samples from many distributions) • How do they generate it? • How can we test their randomness?

  3. Properties of Random Numbers • A sequence of random numbers, R1, R2, . . ., must have have two important statistical properties, uniformity and independence • Each random number Ri, should be an independent sample from the continuous uniform distribution between 0 and 1

  4. Properties of Random Numbers • Some consequences of the uniformity and independence properties are • If the interval (0,1) is divided into n subintervals of equal length, the expected number of observations in each interval is N/n, where N is the total number of observations • The probability of observing a value in a particular interval is independent of the previous values drawn

  5. Pseudo-Random Numbers • pseu·doadj. False or counterfeit; fake. [American Heritage Dictionary] • Because these numbers are produced using a deterministic algorithm • Given the method, the set of random numbers produced can be replicated • Thus they are not truly random • They simply imitate the properties of uniform distribution and independence • A statistical test should conclude they are indistinguishable from true random numbers • Thus, they can be used for all practical purposes instead of true random numbers

  6. Considerations in Generating Pseudo-Random Numbers • The routine should be fast ( A simulation may require billions of RNs) • The routine should be portable to different environments • The routine should have a sufficiently long cycle • The random numbers generated should be replicable (Useful in debugging and comparing systems) • The random numbers generated should imitate the statistical properties of uniformity and independence

  7. Linear Congruential Method • This method produces a sequence of integers between 0 and m-1 according to the following recursive relationship: • The initial value “X0” is called the seed, “a” the constant multiplier, “c” the increment, and “m” the modulus • If c  0, the form is called the mixed congruential method • if c = 0, the form is called the multiplicative congruential method • The choice of the parameters affect the statistical properties and the cycle length • To convert the integers to random numbers use Ri = Xi /m

  8. Example • X0 = 27, a = 17, c=43, and m = 100 (Ri = Xi /100) • X0 = 27 • X1 = (17*27+43) mod 100 = 502 mod 100 = 2 (P1 = .02) • X2 = (17*2+43) mod 100 = 77 mod 100 = 77 (P2 = .77) • X3 = (17*77+43) mod 100 = 1352 mod 100 = 52 (P3 = .52) • . . .

  9. Linear Congruential Method • Maximum density (no gaps in the distribution): • The numbers generated with this method can only assume values from the set I = {0, 1/m, 2/m, . . ., (m-1)/m} • Thus Ri’s are actually distributed with a discrete distribution defined over I • This can be accepted as an approximation given that m is large enough • Maximum period (avoid cycling, autocorrelation) • Cycle length (P) depends on the choice of parameters (always less than m) • For m = 2b, c  0 and relatively prime to m and a = 1+4k, the longest possible period P = m. • For m = 2b, c = 0, X0 (seed) odd, and a = 3+8k or a = 5+8k, the longest possible period P = m/4 • For m a prime number, etc.. P = m-1

  10. Example • Use multiplicative congruential method with a = 13, m = 26 = 64 and X0 = 1, 2, 3, 4 X0 = 1, I = {1, 5, 9 ,13, …, 53, 57, 61} Gap = 4/64 = 0.0625

  11. Combined Linear Congruential Generators • To simulate more complex systems, the simulation runs need to go through larger numbers of elementary events • This means that kind of simulation runs have to use more random numbers • In order to have healthy runs, pseudo-random generators with longer periods are needed (So that cycles can be avoided during the run) • It is possible to combine two or more multiplicative congruential generators in such a way that the combined generator has good statistical properties and a longer period

  12. Random-Numbers Streams and Seeds • The seed for a random-number generator: • Is the integer value X0 that initializes the random-number sequence. • Any value in the sequence can be used to “seed” the generator. • A random-number stream: • Refers to random numbers obtained by using a starting seed • If the streams are b values apart, then stream i could defined by starting seed: • Older generators: b = 105; Newer generators: b = 1037. • A single random-number generator with k streams can act like k distinct virtual random-number generators • To compare two or more alternative systems. • Advantageous to dedicate portions of the pseudo-random number sequence to the same purpose in each of the simulated systems.

  13. Pseudo-Random Number Generation in SIMAN • SIMAN employs the multiplicative congruential method with a = 16807, m = 231-1 = 2,147,483,647 • This is an almost full-period generator • For any initial seed between 1 and 231-2, all unnormalized random numbers between 1 and 231-2, are generated exactly once before the generator cycles again (P = 231-2) • A SIMAN model may employ several different random-number streams • Each stream is generated by using the same generator with different initial seed values

  14. Pseudo-Random Number Generation in ARENA • With today’s computing power, the cycling can occur in minutes of simulation with with a cycle length of 2 billion (2.1x109) • ARENA thus uses a combined multiple recursive generator which combines two separate generators

  15. Pseudo-Random Number Generation in ARENA • The cycle length of this generator is 3.1x1057 • This is inexhaustible with the current computing speeds • Just to generate them would take 1040 millennia (thousand years) on a 2GHz PC • The Arena generator has facility to split this cycle into 1.8x109 separate streams, each of length 1.7x1038 • Each stream is further subdivided into 2.3x1015 separate substreams of length 7.6x1022 apiece

  16. Tests for Random Numbers • Two categories: • Testing for uniformity: H0: Ri ~ U[0,1] H1: Ri ~ U[0,1] • Failure to reject the null hypothesis, H0, means that evidence of non-uniformity has not been detected. • Testing for independence: H0: Ri ~ independently H1: Ri ~ independently • Failure to reject the null hypothesis, H0, means that evidence of dependence has not been detected. • Level of significance a, the probability of rejecting H0 when it is true:a = P(reject H0|H0 is true) / /

  17. Tests for Random Numbers • When to use these tests: • If a well-known simulation languages or random-number generators is used, it is probably unnecessary to test • If the generator is not explicitly known or documented, e.g., spreadsheet programs, symbolic/numerical calculators, tests should be applied to many sample numbers. • Types of tests: • Theoretical tests: evaluate the choices of m, a, and c without actually generating any numbers • Empirical tests: applied to actual sequences of numbers produced.

More Related