# Nepco

Topics: Random variable, Cumulative distribution function, Randomness Pages: 20 (7212 words) Published: April 18, 2013
Notes For Simulation Theory (ESE 603)
Michael A. Carchidi March 14, 2013
Chapter 7 - Random-Number Generation Random number are a necessary basic ingredient in the simulation of almost all discrete systems. You may never have to write a computer program to generate random numbers because all simulation software have built-in subroutines, objects, or functions that will generate random numbers. However, it is still important to understand the basic ideas behind the generation (and testing) of random numbers. These random numbers are then used (Chapter 8) to generate other random variables. This chapter describes the generation of random numbers and their subsequent testing for randomness (uniformity and independence), but ﬁrst we discuss some basic properties of random numbers. 7.1 Properties of Random Numbers A sequence of random numbers {R1 , R2 , R3 , . . . , Rn , . . .} must have two important properties: (a) uniformity and (b) independence.

Each random number Ri is an independent sample drawn from a continuous uniform distribution between zero and one (i.e., U[0, 1)) whose pdf and cdf are given by ⎧ ⎧ x≤0 x 0

(m1 − 1)/m1 , for Xi = 0

k k Y µ mj − 1 ¶ 1 Y . (mj − 1) = 2 P = k−1 2 2 j=1 j=1

Example #3: Still Another Linear Congruence Using k = 2 generators with a1 = 40, 014, a2 = 40, 692, m1 = 2, 147, 483, 563 and m2 = 2, 147, 483, 399 leads to Xi+1,1 = 40, 014Xi,1 mod(2, 147, 483, 563) 10

and Xi+1,2 = 40, 692Xi,2 mod(2, 147, 483, 399) and and Ri = ⎧ ⎨ Xi /2, 147, 483, 563, ⎩ Xi = (Xi,1 − Xi,2 ) mod(2, 147, 483, 563 − 1) for Xi > 0 .

2, 147, 483, 562/2, 147, 483, 563, for Xi = 0

Using seeds X0,1 in the range [1, 2, 147, 483, 562] and X0,2 in the range [1, 2, 147, 483, 398], this generator leads to a period of P = (2, 147, 483, 562)(2, 147, 483, 398) = 2, 305, 842, 648, 436, 451, 838 2

or P = 2.3 × 1018 , which (in seconds) is 4.6 times larger than the accepted age of the known universe (5 × 1017 seconds). ¥ Perhaps surprisingly, even such a long period may not be adequate for all applications and combined generators have been used having periods as large as 2191 ' 3.1 × 1057 ! Considering the fact that the approximate number of electrons on the earth is less than mass of earth 5.98 × 1024 kg = = 6.6 × 1054 , mass of an electron 9.11 × 10−31 kg

the number 2191 is quite large. Wow! To tell you the truth, I can not image why a period this large would be needed in real world applications. 7.4 Tests for Random Numbers The desirable properties of random numbers - uniformity and independence were discussed earlier. To insure that these desirable properties are achieved, a number of statistical tests can be performed on the generated numbers. Note that the appropriate statistical tests have already been performed on generators used for most commercial simulation software because, without a dependable random number generator, any simulation that uses this random-number generator would not yield valid results. The tests we shall discuss are as follows. 11

• Test for Uniformity • Frequency Test: Uses the Kolmogorov-Smirnov (KS) and/or the chisquared (χ2 ) test to compare the distribution of the set of generated numbers to the standard uniform distribution U[0, 1). • Tests for Independence • Runs Test: Tests the runs up and down or the runs above and below the mean by comparing the actual values to expected values. The statistic for comparison are the Standard Normal Distrbution and The ChiSquared Distribution. • Autocorrelation Test: Tests the correlation between the generated numbers and compares the sample correlation to the expected correlation of zero. The statistic for comparison is the Standard Normal Distrbution. • Gap Test: Counts the number of digits that appear between repetitions of a particular digit and then uses the Kolmogorov-Smirnov (KS) test to compare this with the expected size of gaps. The statistic for comparison is the Geometric Distrbution. • Poker Test: Treats numbers...