the effect of random number generators on applications

39
University of Central Florida University of Central Florida STARS STARS Retrospective Theses and Dissertations Fall 1980 The Effect of Random Number Generators on Applications The Effect of Random Number Generators on Applications Edwin G. Landauer University of Central Florida Part of the Engineering Commons Find similar works at: https://stars.library.ucf.edu/rtd University of Central Florida Libraries http://library.ucf.edu This Masters Thesis (Open Access) is brought to you for free and open access by STARS. It has been accepted for inclusion in Retrospective Theses and Dissertations by an authorized administrator of STARS. For more information, please contact [email protected]. STARS Citation STARS Citation Landauer, Edwin G., "The Effect of Random Number Generators on Applications" (1980). Retrospective Theses and Dissertations. 496. https://stars.library.ucf.edu/rtd/496

Upload: others

Post on 07-Dec-2021

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The Effect of Random Number Generators on Applications

University of Central Florida University of Central Florida

STARS STARS

Retrospective Theses and Dissertations

Fall 1980

The Effect of Random Number Generators on Applications The Effect of Random Number Generators on Applications

Edwin G. Landauer University of Central Florida

Part of the Engineering Commons

Find similar works at: https://stars.library.ucf.edu/rtd

University of Central Florida Libraries http://library.ucf.edu

This Masters Thesis (Open Access) is brought to you for free and open access by STARS. It has been accepted for

inclusion in Retrospective Theses and Dissertations by an authorized administrator of STARS. For more information,

please contact [email protected].

STARS Citation STARS Citation Landauer, Edwin G., "The Effect of Random Number Generators on Applications" (1980). Retrospective Theses and Dissertations. 496. https://stars.library.ucf.edu/rtd/496

Page 2: The Effect of Random Number Generators on Applications

THE EFFECT OF RANDOM NUMBER GENERATORS ON Al)PLICATIONS

BY

EDHIN G. LANDAUER B.S., Portland State University, 197 3

M.S. T., Portla·nd State University., 1975 M.S~~ Montana State University, 1977

RESEARCH REPORT

Submitt e d in partial fulfillment of the requirements for t he degree of Master of Science

i1 t-_he Graduate Studies Program of the College of Engineering at the

Universi ty of Central Florida; Orlando, Florida

Fall Quarter 1980

Page 3: The Effect of Random Number Generators on Applications

ABSTRACT

Several pseudorandom number generators are described

and compared on the basis of cost of generation and length

of period of the sequences that are produced. The major

statistical tests, which are used to obtain a measure of

randomness for the different generators are discussed

and compared.

F our pseudorandom number generators are programmed

in GPSS and are used to generate interarrival and service

times for an M/M/1 queuing system. The results of each

of the trials are compared to the theoretical results

which can be obtained from queuing theory.

Page 4: The Effect of Random Number Generators on Applications

ACKNOWLEDGMENTS

I would like to thank the members of my graduate

committee, Drs. Harold I. Klee, Darrell G. Linton, and

ChristianS. Bauer, Jr., for their time and effort helping

me to complete this study. I would like to thank my wife,

Beth, for putting up with the long hours I had to spend

at the Computer Center.

iii

Page 5: The Effect of Random Number Generators on Applications

TABLE OF CONTENTS

ACKNOWLEDGMENTS I I I I I I • I I I I I I I I I I f'

Chapter

1. INTRODUCTION

2. DESCRIPTION OF THE GENERATORS

J. DESCRIPTION OF THE STATISTICAL TESTS

4. DESCRIPTION OF THE MAIN PROGRAM AND

SUBROUTINES .

5. COMPARISON OF THE SIMULATION RESULTS AND

THEORETICAL RESULTS .

6. CONCLUSION

APPENDIX

REFERENCES

iv

iii

1

2

7

15

19

23

24

34

Page 6: The Effect of Random Number Generators on Applications

Chapter 1

Introduction

In most of the research that has been done on pseudo­

random number generators in recent times, the major eff'ort

has been to determine how the generators fare using sev­

eral statistical tests. Therefore, a pseudorandom number

generator is labeled as good or bad without even looking

at the results of its use.

There are four basic pseudorandom number generators

that are either used now or have been used in the past.

These are the midsquare method, the modified midsquare

method, the Fibonacci method, and the multiplicative con­

gruential method. There are several other methods in use

at this time, but they are usually a modification and/or

combination of these four basic methods.

The purpose of this study is to compare the results

of a simulation study involving these four basic genera­

tors. The study consists of (1) a description of each of

the four generators that will be compared, (2) a descrip­

tion o£ the basic statistical tests that have been tried

and the results of these tests, (J) a description of the

main program and subroutines, (4) a comparison of these

four generators using a queuing simulation and theoretical

results which can be obtained from queuing theory, and (5)

. conclusions that can be drawn from this study.

Page 7: The Effect of Random Number Generators on Applications

Chapter 2

Description of the Generators

One of the earliest methods was the midsquare method

developed by John von Neumann. In this method, the start­

ing or seed number and the number of digits are specified.

This number is squared and the middle digits are used as

the first number of the sequence. For example, let the

starting number be 7249, then 72492 is 52548001, so the

first number of the sequence is the middle four digits

5480. Repeating this procedure will generate additional

pseudorandom numbers. This generator has a serious dis-

advantage. For example, the sequences 3792,3792,3792, ... ,

and 3317,0024,0005,0000,0000, ... , illustrate the weakness

of this generator. Numbers of the form OOAB and ABOO have

a tendency to appear and eventually lead to 0000. It is

used in this study for comparison purposes only.

A modification of the midsquare method eliminates

some of these disadvantages. For this method, one starts

out with a seed number and a multiplier. For example, let

the seed be 2907 and the multiplier be 8537· Multiply the

seed number by the multiplier to get 24817059. The middle

four digits 8170 become the first number of the sequence

and the last four digits 7059 become the new seed number.

Page 8: The Effect of Random Number Generators on Applications

3

The original multiplier is then multiplied by the new seed

number to continue the sequence.

If either the seed or multiplier were even, all seed

numbers that follow would be even. This could lead to

0000 as a possible seed. I£ both were odd, the product

would be odd, eliminating the possibility of 0000 occur-

ring. Also, if either the seed or multiplier were to end

in 5, every succeeding seed would end in 5. Therefore,

the only favorable last digits for the seed and multiplier

are l,J,?, and 9. So if one is using a 4-digit number,

only 4000 or four-tenths are favorable. Therefore, the

maximum period is 4000. (If the seed and multiplier are

both 8-digit numbers, the maximum period would be forty

million.) This generator is fairly well recognized even

though the period is quite short compared to many others.

The third method, called the Fibonacci method, gen-

erates numbers using the formula

xn+l = xn + xn-1 (mod m) .

For example, let x0 be 54, let x1 be . 896, and let m be

1000, then x2 is 950, x3

is 846, and so on. It is easy

to see that if m is very large, it is possible to have

sequences developing. For example, let m be 23 1 , let x 0

be 1, and let X1 be 2. Then the sequence J,5,8,1J,21, ·. ·

would arise. Needless to say, this generator can be seri-

ously deficient. It was tried because of its computa­

tional simplicity, i.e. one addition is required for each

Page 9: The Effect of Random Number Generators on Applications

4

number generated and consequently it is inexpensive to use.

It is also used in this study for comparison purposes

only.

The last method is called the multiplicative congru­

ential generator proposed by D. H. Lehmer. The form of

this generator is

xn+1 = axn (mod m) .

The modulus m is usually of the form m=2r since the binary

system is used on most computers. As an example of this

generator, let a be 5, let m be 24 or 16, and let x0

be 1.

Then

xl - ( 5) ( 1) 5 (mod 16) = -

x2 - L5) (5) - 9 (mod 16)

X3 - (5) (9) - 13 (mod 16)

x4 - (5)(13) - 1 (mod 16) .

The period of this generator is 4 4-2 =2 . It has been

proven that the period of this generator will always be

2 r-2 when m=2 r (I,fewman and Odell, 1971) 0

The pseudorandom number generator used in GPSS (Gen­

eral Purpose Simulation System) is a modification of both

the multiplicative congruential generator and the modified

midsquare generator. The GPSS generator will be used in

this study as the fourth generator. There are three kinds

of numbers, called multipliers, seeds, and indices, that

are used in this generator. At any one time, there are

eight of each of these numbers stored in 8X1 arrays in the

Page 10: The Effect of Random Number Generators on Applications

5

generator. The GPSS programmer has the option of selec­

ting any one of eight pseudorandom number generators.

These generators are not independent of one another, how-

ever. Each of the eight multipliers is a positive integer

less than 23 1 that does not change during use of the gen­

erator and cannot be altered by the programmer. The

seeds are also positive integers less than 23 1 but can be

altered by the programmer and are changed during operation

of the generator. The indices are integers in the range

0- 7 (they can be represented by three bits) and are all

initially zero.

The procedure that is used when a random number is

n eeded is the following: The programmer specifies which

random number generator to use (RN1-RN8). The corre-

sponding value in the index array points to one of the

words in the multiplier array. Th e index array initially

contains all zeros, so the first multiplier will be the

first word in the array. The appropriate number in the

seed array (which also depends on which generator is

selected) is multiplied by the multiplier found above.

This produces a 62-bit product. The low order 32 bits are

then checked. If the highest order bit is 1, the two's

complement of the 32 bits replaces the original 32 bits .

This is to make sure the resulting number is positive.

The low order 31 bits of the product become the new seed

and are stored in the appropriate place in the seed array

Page 11: The Effect of Random Number Generators on Applications

6

to be used the next time a pseudorandom number is called

for. Three bits of the high order 16 bits of the 62-bit

product are stored in the appropriate word in the index

array. The middle 32 bits o£ the 62-bit product are used

to obtain the next random number. If the random number

needed is a fraction, the middle 32 bits are divided by

10 6 and the remainder is a six-digit fractional random

number. I£ an integer random number is desired, the

middle 32 bits are divided by 103 and the remainder be-

comes the thr ee-digit random number (Maisel and Gnugnoli,

1972).

Page 12: The Effect of Random Number Generators on Applications

Chapter 3

Description of the Statistical Tests

There are a ~reat number of t ests that could be used

to obtain a quantitative measure of randomness for the

different pseudorandom number generators. Seven of the

most common empirical tests will be discussed along with

one general statistical test which is used with each of

the other seven tests.

Two questions that come to mind are: Why are so many

tests needed? Why isn't there one test that could be used

to determine if a sequence behaves as if it is random?

The answer is that each test is used to determine the

randomness of the sequence with respect to one particular

property. Even if a sequence can pass a number of' these

tests, one is not assured that it can pass any others.

In normal practice, however, if' a sequence can pass five

or six of these tests, it is assumed that the sequence is

random (Knuth, 1969).

The general statistical test that is used is the Chi-

square test. For this test, n independent observations

are taken where every observation can fall into one of k

categories. If Y. is the number of observations that f all 1

into category i and p. is the probability of any observa-1

Page 13: The Effect of Random Number Generators on Applications

8

tion falling intc category i, the statistic X2 can be

calculated where

k

~ (Y. - np.) 2

l 1

i=l

This statistic, X 2 , is compared to a tabled entry from a

Chi-square distribution with lr= k -1 degrees of freedom.

If this statistic, ·x 2 , is greater than the 1-percent table

entry, the numbers are rejected as not sufficiently random

(this percentage is just a suggestion). Usually each test

is run at least three times on different data sets and the

numbers are considered not s uff iciently random if they are

rejected at least two out of the three times.

This is a brief description of the Chi-square test

and how it can be applied to a set of n independent ob-

servations. It will now be shown how this test can be

used in conjunction with seven empirical tests. For each

of the tests, let u0 ,u1 ,u2 , ... ,Un~ represent a sequence

which is believed to be uniformly distributed between 0

and 1. Define the sequence Y0 ,Y1 ,Y 2 , ... ,Yn_1by the rule

Yi= [dui] where [x] is the largest integer less than or

equal to X whose sign is the same as X, and where d can

change from test to test. Thus, the second sequence

consists of integers which will be uniformly distributed

between 0 and d-1 if the sequence u0 ,u1 ,u2 , ... ,Un~is

uniform between 0 and 1.

Page 14: The Effect of Random Number Generators on Applications

9

The first empirical test is call.ed the Equidistri-

bution test or Frequency test. A number d is chosen, for

example 100. Start with the sequence of Y.'s and count l

the number of times that Y. =r for each 0 ~ r < d, and l

O~i~n. A Chi-square test can now be applied to these

counts using k=d categories and a probabil ity for each

category of 1/d.

The Serial test is used to determine if pairs of

successive numbers are uniformly distributed. Just as in

the Equidistribution test, a number d is chosen and a

count of all possible pairs (Y2 i,YZi+ 1 ) = (q,r) is made

for 0~ i<n and 0~ q,r.(d. There are k=d2 categories,

each with probability 1/d2 , and so a Chi-square test is

applied to these counts. It should be noted that there

can not be any overlap on the pairs of successive numbers,

otherwise they are not independent. Thus, the pairs

(Y1

,Y 2 ), (Y 2 ,Y3

) are not allowed. This test could be

increased to triples or quadruples, but the number of

categories increases rapidly and therefore d would have

to be reduced.

The Gap test is used to determine the length of gaps

between occurrences of a U in a particular range. Pick

two numbers o<. and (3 such that 0~ ~ <j3 ~ 1 and find sub-

sequences such as Ui,Ui+l'Ui+ 2 , ... ,Ui+r where each of

Ui,Ui+l'Ui+ 2 ' ... ,Ui+r- 1 is not betweencx: and j3 but Ui+r

is. This subsequence represents a gap of length r.

Page 15: The Effect of Random Number Generators on Applications

10

Counts are made for gaps of length 0,1,2, ... ,tor more,

where values of n and t are chosen so that each count is

expected to be 6 or more. The probabilities for each of

the categories

and

are easily found to

Po = p,

p1 = p(l-p),

Pz = p(1-p)2,

t Pt or more = {l-p ) '

be

where p = (3 -oe (Knuth, 1969). After all the counts have

been made, a Chi-square test is applied to the results.

The Poker test or Partition test is used to determine

the number of distinct values in a set of five random

numbers. The five possible categories are:

5 different = all dif'ferent

4 different = one pair

J different = two pair or three of

2 di:fferent = full house or four of

1 different = five of a kind.

The probabilities for each group are found to be

p = d ( d -1 ) · • • ( d-r+ 1 ) { 5 }

a kind

a kind

r d5 r

where { ~} are the Stirling numbers (Knuth, 1969). This

formula is found by counting how many of the d5 quint up les

Page 16: The Effect of Random Number Generators on Applications

11

of numbers between 0 and d-1 have exactly r different

elements and dividing by d5. Now, d(d-l)(d-2) ·· ·(d-r+l)

is the number of ordered choices of r things taken from

a set of d objects and{~} is th~ number of ways to par­

tition a set of 5 objects into exactly r different values.

Again, a Chi-square test can be applied to the results of

the counts.

The Coupon Collector's test is designed to observe

the lengths of sequences required to get a complete set

of integers from 0 to d-1. This test is similar to col-

lectin g d coupons which are randomly distributed in break-

fast cereal boxes-- how many boxes of _cereal must be con­

sumed before the complete set of coupons is obtained?

Counts are obtained for the categories d,d+l,d+2, ... ,t,

where t includes everything greater than t. The value of

t is determined such that the expected number of observa-

tions in each category is at least six. The corresponding

probabilities are given by

and

{ r-1} d-1 . '

d~r<.t

Pt = 1 - dl {td-1} dt-1

To obtain these formulas, let q be the probability that r

a subsequence of length r is incomplete

qr = 1 - d! { r} dr d ,

Page 17: The Effect of Random Number Generators on Applications

12

which is derived from the probability in the Poker test.

Thus, an r-tuple of elements is obtained that does not

have all different values. The desired probabilities

follow from the relations

d~ r <:. t

and

Pt = qt-1

(Knuth, 1969). A Chi-square test is applied to the counts

to complete the analysis.

The next test to be described is the Test on Subse-

quences. In many programs, several sequences of random

numbers may be needed at the same time. For example, if

a program calls for four sequences of random numbers, then

it is necessary to have the subsequence of every fourth

number be random. Therefore, each of the subsequences can

be put through the tests that were described above to

determine if they are satisfactory.

The final test to be described is the run test. In

this test, a search is made for monotone subsequences of

the original sequence, which can be chosen to be either

increasing or decreasing. For example, consider the

sequence of 3523753921 where it is desired to find "runs

up". Put a vertical line between Xi and Xi+l if Xi> Xi+l

to obtain

Page 18: The Effect of Random Number Generators on Applications

13

Thus, there are 2 subsequences of length 2, one sequence

of length 3 and 3 sequences of length 1. Knuth (1969) has

determined that a long run will tend to be followed by a

short run. Therefore, adjacent runs are not independent

and a Chi-square test cannot be used. It has been shown

by Knuth (1969) that the statistic

2 1 6 6 = n L f [c ( i ) - nbi ] [c(j) - nbjJ aij

i= 1 j= 1

where the C(i)'s and C(j)rs are th e number of observations

i n the categories 1,2,],4,5, a n d 6 or more, has a Chi-

square distribution with six degrees of freedom. The

coefficients a .. and b. are l J l

giv en as

all a12 a13 a14 a15 a16

a21 a22 a23 a24 a25 a26

a31 a32 a33 a34 a35 a36

a41 a42 a43 a44 a45 a46

a 51 a 52 a 53 a 54 a 55 a 56

a61 a62 a63 a64 a65 a66

4529.4 9044.9 13568 18091 22615 27892

9044.9 18097 27139 36187 45234 55789

13568 27139 40721 54281 67852 83685 =

18091 ]6187 54281 72414 90470 111580

22615 45234 67852 90470 113262 139476

27892 55789 8]685 111580 139476 172860

and

Page 19: The Effect of Random Number Generators on Applications

14

[b1 b2 bJ b4 b5 b~

= [ i 11 120

19 720

29 5040

The weakest of all the tests that have been described

is the Equidistribution test. The Run test is considered

the strongest test based on the fact that very few random

number generators can pass it (Knuth, 1969).

Page 20: The Effect of Random Number Generators on Applications

Chapter 4

Description of the Main Program and Subroutines

The application used for this study was the M/M/1

queuing system. The study was done in GPSS with the basic

program being the same for all cases with just the random

number generator being changed. The basic program that

was used was the following:

SIMULATE

XPDIS FUNCTION ,C24

0,0/.1 •. 104/.2,.222/.J,.J55/.4, .509/.5 •. 69/.6,.915/-7.1.2/

-75,1.J8/.8,1.6/.84,1.8J/.88,2.12/.9,2.J/.92,2.52/

.94,2.81/.95,2.99/.96,J.2/.97.J.5/.98,J.9/.99,4.6/

.995.5-J/.998,6.2/.999.7/-9997.8

*

*

*

SERVE STORAGE 1

2

1

TABLE

QTABLE

GENERATE

QUEUE

ENTER

DEPART

M1,0,10,70 TABLE OF TOTAL TIME IN

SYSTEM

1,0,10,70 TABLE OF TOTAL TIME IN

QUEUE

90,FN$XPDIS INTERARRIVAL TIME IS 90

SECONDS

1

SERVE

1

ENTER QUEUE

START SERVICE

DEPART QUEUE

Page 21: The Effect of Random Number Generators on Applications

16

ADVANCE 60,FN$XPDIS SERVICE TIME IS 60 SECONDS

LEAVE SERVE END SERVICE

TABULATE 2 OBTAIN DISTRIBUTION OF

* TRANSACTION TRANSIT TIMES

TERMINATE TRANSACTION IS REMOVED FROM

* SYSTEM

GENERATE 14400 RUN FOR 4 HOURS

TERMINATE 1

START 20 RUN FOR 20 TIME PERIODS TO

* OBTAIN STEADY STATE

RESET

START 42 RUN FOR 1 WEEK

END END OF SIMULATION

The subroutine for calculating random numbers for the

midsquare method is:

*

*

INITIAL

ONE VARIABLE

TWO VARIABLE

FOUR VA-RIABLE

SIX VARIABLE

ASSIGN

X$RNDM,6813

X$RNDM*X$RNDM

(Pl/100)*100

(Pl/1000000)*1000000

(V$TWO-V$FOUR)/100

1, V$ONE OBTAIN SQUARE OF OLD RANDO M

NUMBER

SAVEVALUE RNDM,V$SIX CALCULATE NEW RANDOM NUMBER

AND SAVE IN RNDM

The word RNDM is placed in the FUNCTION statement in the

original program.

Page 22: The Effect of Random Number Generators on Applications

17

For the modified midsquare method, the subroutine is

the following:

INITIAL X$RNDM,J729/X$MULT,J729

ONE VALIABLE 5167*X$MULT

TWO VARIABLE (Pl/100)*100

THREE VARIABLE (Pl/10000)*10000

FOUR VARIABLE (Pl/1000000)*1000000

FIVE VARIABLE Pl-V$THREE

SIX VARIABLE (V$TWO-V$FOUR)/100

ASSIGN 1,V$ONE FIND PRODUCT OF SEED NUlVIBER

* AND MULTIPLIER

SAVEVALUE RNDM,V$SIX NEW RANDOM NUMBER

SAVEVALUE MULT,V$FIVE NEW MULTIPLIER

Just as before, the word RNDM is placed in the FUNCTION

statement of the main program.

*

*

The subroutine for the Fibonacci method is:

INITIAL X$RNDM1,58/X$RNDM2,5147

ONE FVARIABLE (X$RNDM1/2) + (X$RNDM2/2)

TWO VARIABLE (V$ONE/107J741824)*1073741824

THREE FVARIABLE ((X$RNDM1/2)+(X$RNDM2/2)-V$TW0)*2

ASSIGN 1,V$THREE ADD PREVIOUS TWO NUMBERS

TOGETHER

SAVEVALUE RNDM1,X$RNDM2 MOVE NUMBERS BACK IN

THE SEQUENCE

SAVEVALUE RNDM2,P1 NEW RANDOM NUMBER

For this subroutine, the word RNDM1 is used in the

Page 23: The Effect of Random Number Generators on Applications

18

FUNCTION statement of the main program.

For the fourth method, the built-in GPSS random

number generator was used. In this case, the word RN1

was placed in the FUNCTION statement of the main program.

Page 24: The Effect of Random Number Generators on Applications

Chapter 5

Comparison of the Simulation Results and Theoretical Results

Six simulation runs were made for each of the four

generators. Trial runs were made to determine when steady

state was reached and it was determined that after 80

hours (20 increments of 4 hours each), all of the results

had settled down. It was noted that the midsquare method

was the first to reach steady state after only 8 to 12

hours and that the GPSS generator was the last to reach

steady state. After steady state was reached, all the

statistics were reset to 0 and the actual simulation

started. The duration of each run was for one week (168

hours) .

The runs were further broken down into three runs

from each generator corresponding to different seeds with

an interarrival time of 120 seconds and a service time of

60 seconds. This was repeated for an interarrival time

of 90 seconds and a service time of 60 seconds. For each

run, two tables were printed (Tables 1 and 2) . The first

one was for the distribution of queue times and the second

was for the distribution of the total time a customer was

in the system. The time interval for the tables was 10

Page 25: The Effect of Random Number Generators on Applications

20

seconds starting with 0 seconds and continuing until there

was an expected number of less than six in an interval

based on the theoretical distributions. For the (120,60)

case, the queue table stopped at 430 seconds and the total

time table stopped at 480 seconds. For the (90,60) case,

the queue table continued to 640 seconds and the table of

total times ended at 680 seconds.

From queuing theory, the cumulative distribution

function for the time spent in the queue is

w (t) = q 1 - f> 1 - .0 e- (}A. - ~ ) t

I

t = 0

t > 0

where A is the mean arrival rate,){ is the mean service

rate and ;0 =; (Gross and Harris, 1974). The cumulative

distribution function for the total time spent in the

system is

W ( t) = 1 - e- (J.A- )\) t t > 0.

Using these two formulas, tables of the theoretical

(expected) results can be obtained to compare to the

simulation results. The endpoint of the time interval

needs to be increased by one second for the theoretical

results to account for the truncation that takes place

in GPSS. For example, the interval, 70 to 80, for the

simulation results corresponds to the theoretical inter-

val, 71 to 81.

The statistical test that is used to evaluate the

results is the Chi-square test that was described earlier.

Page 26: The Effect of Random Number Generators on Applications

21

The statistic .X 2 can be calculated and this statistic is

then compared to a tabled entry from a Chi-square distri­

bution with V = k-1 degrees of freedom. If this statistic

)( 2 is greater than the 1-percent entry, the simulation

output cannot be assumed to conform with the theoretical

distributions. The test is run three times with each

generator (with a different seed each time) and the

hypothesized distribution is rejected if at least two of

the three runs yield statistics not in the interval. This

is the same procedure that is used for testing sequences

of random numbers.

Tables 3 and 4, in the appendix, list all of the Chi­

square statistics that were obtained from the 24 different

runs. The critical Chi-square values that were obtained

from a table of the Chi-square distribution are given at

the bottom of each column of these tables. It can be seen

by comparing the values from these tables, that the simu-

lation runs using the GPSS random number generator pass on

at least 2 of the J runs for each of the four cases con-

sidered. The runs involving the other three generators

failed in every case.

Three other values were computed from each run and

compared to the theoretical values. These three are the

expected queue length

2 E(L ) = P , q 1-f'

Page 27: The Effect of Random Number Generators on Applications

22

the expected waiting time

E(W ) = ~ q )).-0/r-:-L---=--)\-....-)

and the expected time spent in the system

E (W) = 1 .,A.A.-.:\

(Gross and Harris, 1974). Tables 5 and 6 contain the

simulation values for each of these terms with the theo-

retical values listed at the bottom of each column. Again,

only the runs involving the GPSS random n umber generator

are close to the theoretical results.

As was stated earlier, the modified midsquare method

is fairly well recognized as producing satisfactory

sequences of random numbers. Since it produced such poor

results using the M/M/1 queuing system, it was subjected

to three of the previously mentioned tests. They were

the Equidistribution test, the Gap test, and the Run test.

Table 7 lists the Chi-square statistics for each test for

each of the three runs using the same seed numbers as

before. The critical values of the Chi-square distribu-

tion are listed in the last row of the table. The gener-

ator produced satisfactory results for all three runs for

both the Equidistribution and Run tests and for two of

the three runs of the Gap test. Therefore, based on the

results of these three tests, this generator does produ ce

satisfactory sequences of random numbers.

Page 28: The Effect of Random Number Generators on Applications

Chapter 6

Conclusion

After comparing the results of all the simulation

runs, it is obvious that the GPSS random number generator

is the only one that produces results . in agreement with

queuing theory. The modified midsquare method has been

recognized as a fairly good generator, but in this study

it was found to be no better than the other two generators

which have recognized deficiencies. This study does not

provide conclusive evidence that the modified midsquare

method is a poor random number generator. It does show,

however, that it does provide poor results for the M/M/1

queuing system with certain interarrival and service times.

The result of this study is that if a random number

generator is needed for a particular model, a generator

must be obtained that will give satisfactory results for

that model. Even though a generator can pass several of

the statistical tests, it will not produce satisfactory

results for all applications.

Page 29: The Effect of Random Number Generators on Applications

A.PPENDIX

Page 30: The Effect of Random Number Generators on Applications

25

Table 1

Queue Time Distribution for Interarrival Time of 120 Seconds and Service Time of 60 Seconds

Entries in Table 5042

Upper Limit

0 10 20 30 40 50 60 70 80 90

100 110 120 130 140 150 1 60 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370

Mean Argurnent 58.686

Observed Frequency

2556 190 176 170 156 152 108 137 108 115

93 97 87 74 68 73 53 52 36 37 39 40 32 27 22 27 32 34 20 14 11 16 21 13 17

7 15 15

Standard Deviation 100.250

Per Cent of Total

50.69 J.76 J.49 J.J7 3.09 3.01 2.14 2.71 2.14 2.28 1.84 1.92 1.72 1.46 1.]4 1.44 1.05 1.0]

.71

.7J

.77

.79

.6]

.53

.43

.53

.63

.67

.J9

.27

.21

.31

.41

.25

.JJ

.13

.29

.29

Page 31: The Effect of Random Number Generators on Applications

Upper Limit

J80 390 400 410 420 4JO

Overflow

26

Table 1-Continued

Observed Frequency

10 7 6 3 5 5

66

Per Cent of Total

.19

.1J

.11

.os

.09

.09 1.26

Page 32: The Effect of Random Number Generators on Applications

27

Table 2

Total Time Distribution for Interarrival Time of 120 Seconds and Service Time of 60 Seconds

Entries in Table 5043

Upper Limit

0 10 20 30 40 50 60 70 80 90

100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370

Mean Argument 117.494

Observed Frequency

44 423 348 340 325 273 280 239 213 190 177 211 164 152 145 132 104 117 110

90 65 68 74 59 37 55 47 45 41 41 34 31 18 17 28 30 26 21

Standard Deviation 116.812

Per Cent of Total

.. 87 8.J8 6.90 6.74 6.44 5.41 5.55 4.?3 4.22 J.?6 J.50 4.18 3.25 3.01 2.87 2.61 2.06 2.32 2.18 1.78 1.28 1.34 1.46 1.16

.73 1.09

.93

.89

.81

.81

.67

.61 ·35 ·33 .55 .59 .51 .41

Page 33: The Effect of Random Number Generators on Applications

Upper Limit

380 390 400 410 420 4JO 440 450 460 470 480

Overflow

28

Table 2-Continued

Observed Frequency

23 19 14 11 17 14 14

9 10 10

6 82

Per Cent oi' Total

.45 ·37 .27 .21 .JJ .27 .27 .17 .19 .19 .11

1.62

Page 34: The Effect of Random Number Generators on Applications

29

Table J

Chi-square Statistics for Queue Time and Total Time Spent in the System with Interarrival Time of 120

Seconds and Service Time of 60 Seconds

Generator Seed xz x_2 Number (Queue Time) (Total Time)

Midsquare 5432 17496.14 210,000.00

6813 77168.40 112,085.00

21lf5 77168.40 112,085.00

Modified 3729 1154.61 1750.21 Midsquare

6813 1077.63 851.41

1379 1220.37 9]8.56

Fibinacci 45,2145 925.5.3 56J.61

58,5147 902.66 581.98

2J,872J 913.51 589.25

GPSS 3? 47.13 52.20

69125 45.07 51.82

12345 75.]2 58.85

2 X~ ol ,49=74. 91 Chi-square X. ol ,44=68. 68 Critical Values

Page 35: The Effect of Random Number Generators on Applications

30

Table 4

Chi-square Statistics for Queue Time and Total Time Spent in the System with Interarrival Time of 90

Seconds and Service Time of 60 Seconds

Generator Seed x2 y_2 Number (Queue Time) (Total Time)

Midsquare 5432 20396.67 1,093,577.00

6813 26?60.01 40,061.93

2145 267?3.80 40,072.29

Modif'ied 3729 3586.01 2772.20 Midsquare

6813 3568.44 2543.22

1379 3149.91 2647.57

Fibonacci 45,2145 2892.75 2068.64

58,5147 2867.56 20?5.68

23,8723 2891.21 2114.50

GPSS 37 85.81 ?6.17

69125 204.73 217.81

12345 81.77 91.38

Chi-square X ~o1,65=94.4o Critical Values

2 X. ol, 69=99. 22

Page 36: The Effect of Random Number Generators on Applications

31

Table 5

Expected Queue Length, Expected Waiting Time, and Expected Time Spent in the System for an Interarrival

Time of 120 Seconds and Service Time of 60 Seconds

Generator Seed E(Lq) E(W ) E(W) Number q

(Seconds) (Seconds)

lVIidsquare 5432* .000 .0 17.0

6813 .032 1.5 45.0

2145 .032 1.5 45.0

Modified 3729 .127 17.064 74.724 Midsquare

6813 .112 16.847 75.381

1379 .132 18.551 78.505

Fibonacci 45,2145 .118 17.371 79.368

58,5147 .120 17.518 78.087

23,8723 .117 17.283 78.123

GPSS 37 .489 58.686 117.494

69125 .507 60.367 120.367

12345 .457 55.393 114.795

Theoretical .5 60 120

*Using this seed number, the sequence of pseudorandom numbers became all zeros before steady state was reached.

Page 37: The Effect of Random Number Generators on Applications

32

Table 6

Expected Queue Length, Expected Waiting Time, and Expected Time Spent in the System for an Interarrival

of 60 Seconds Time of 90 Seconds and Service Time

Generator Seed E(Lq) E(W ) E(W) Number

q (Seconds) (Seconds)

Midsquare 5432* .000 .000 17.000

6813 .096 7.249 50.749

2145 .096 7.251 50.749

Mo dified 3729 .210 22.187 79.791 Mi dsquare

6813 .185 20.985 79.490

1379 .217 23.155 8].144

Fibonacci 45,2145 .199 22.268 83.376

58,5147 .201 22.478 83.183

23,8723 .198 22.125 82.592

GPSS 37 1.404 123.789 183.384

69125 1.5J2 135.993 196.528

12345 1.203 110.059 169.139

Theoretical 1.333 120 180

*Using this seed number, the sequence of pseudorandom numbers became all zeros before steady state was reached.

Page 38: The Effect of Random Number Generators on Applications

33

Table 7

Chi-square s-~d.tistics for Tests of the Modified Midsquare Method

Seed Number

Equidistribution

3729

6813

1379

Chi-square Critical Values

7.68

8.32

8.35

Test

Gap Run

59.89 14.89

21.97 11.83

22.66 11.75

2 2 2 X.o1,19=36 · 19 X.o1,12= 26 · 22 X.o1,6= 16 · 81

Page 39: The Effect of Random Number Generators on Applications

REFERENCES

Gross, D., and Harris, C. M. Fundamentals of Queuing Theory. New York: John Wiley & Sons, 1974.

Knuth, D. E. The Art of Computer Programming: Vol. 2, Seminumerical Algorithms. Reading, Mass.: Addison­Wesley Publishing Company, 1969.

Landauer, E. G. "Random Numbers: Finding a Good Low Cost Generator." International Journal of Mathematical Education in Science and Technology, forthcoming.

Maisel, H., and Gnugnoli, G. Simulation of Discrete Systems. Chicago: Science Research Associates, 1972.

Newman, T. G., and Odell, P. L. The Generation of Random Variates. New York: Hafner Publishing Company, 1971.

Schriber, T. J. Simulation Using GPSS. New York: John Wiley & Sons, 1974.