On randomness of random number generators
Citation for published version (APA):
Verhaegh, W. F. J. (1989). On randomness of random number generators. (Memorandum COSOR; Vol. 8920). Technische Universiteit Eindhoven.
Document status and date: Published: 01/01/1989
Document Version:
Publisher’s PDF, also known as Version of Record (includes final page, issue and volume numbers)
Please check the document version of this publication:
• A submitted manuscript is the version of the article upon submission and before peer-review. There can be important differences between the submitted version and the official published version of record. People interested in the research are advised to contact the author for the final version of the publication, or visit the DOI to the publisher's website.
• The final author version and the galley proof are versions of the publication after peer review.
• The final published version features the final layout of the paper including the volume, issue and page numbers.
Link to publication
General rights
Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights. • Users may download and print one copy of any publication from the public portal for the purpose of private study or research. • You may not further distribute the material or use it for any profit-making activity or commercial gain
• You may freely distribute the URL identifying the publication in the public portal.
If the publication is distributed under the terms of Article 25fa of the Dutch Copyright Act, indicated by the “Taverne” license above, please follow below link for the End User Agreement:
www.tue.nl/taverne Take down policy
If you believe that this document breaches copyright please contact us at: openaccess@tue.nl
providing details and we will investigate your claim.
EINDHOVEN UNIVERSITY OF TECHNOLOGY Department of Mathematics and Computing Science
Memorandum COSOR 89-20 On randomness of random
number generators W.F.I. Verbaegh
Eindhoven University of Technology
Department of Mathematics and Computing Science P.O. Box 513
5600 MB Eindhoven The Netherlands
Eindhoven, August 1989 The Netherlands
On randomness of random number generators
W.FJ. Verhaegh
Eindhoven University of
Technology
17-8-1989
Abstract
Many computer simulations use random number generators and since most
computer languages have a built-in generator it is very easy just to use
thatone.
However these random number generators can be very non-random.
1.
Introduction
This paper is a warning for them who use random number generators that are already
imple-mented on a computer system. These generators can be very bad for simulations. At least in our
case the random number generator we used had a very bad perfonnance. We were simulating a
queueing network and we wanted to detennine some average waiting time. Among the situations
we simulated were some situations for which we could detennine the average waiting time
analytically, by means of the theory of M
I
Mil-queues [1]. So we were able
tocompare the
results of the simulations to the theoretical values.
We simulated a long run and split this run in ten subruns. Each subrun contained 10,000 arrivals
so the dependency between two subruns was small enough. Then for each subrun we detennined
the experimental average waiting time.
andwe used these values of subrun 2 - 10 to detennine an
estimation for the average waiting time and the standard deviation of this estimation [2].
The results showed something
strange~For example in a situation for which the occupancy-level
was 80
% andfor which
thewaiting time could be detennined like in a M
I
M II-queue, the results
were:
-2-subrun average waiting time
2 4.192 3 4.363 4 4.653 5 4.211 6 4.383 7 4.564 8 3.953 9 4.319 10 4.690 estimation 4.370 standard deviation 0.079
But the theoretical average waiting time is 4. so the results are very unlikely. Therefore we doub-lechecked our simulation algorithm. by tracing the events. but we didn't find any error. The only thing left which could have caused the bad results was the random number generator. So we decided to do the simulation with other sequences of random numbers. We did this by changing the initial seed of the random number generator (we will come back to this soon). The simulation above was done with initial seed Xo = I, the default value. We performed some other simulations and the results were:
subrun average waiting time
Xo= 1234 Xo=236 Xo =528194 2 4.282 2.627 3.692 3 4.281 2.624 3.767 4 4.474 2.625 3.662 5 4.331 2.618 3.506 6 4.286 2.633 3.343 7 4.465 2.603 2.817 8 4.059 2.633 3.281 9 4.417 2.623 3.408 10 4.419 2.619 3.574 estimation 4.331 2.623 3.450 standard deviation 0.044 0.003 0.096
These results are extremely unlikely so we decided to examine the random number generator thoroughly.
2. The random number generator
First we tried to find out what random number generator we had used. This generator was the
standard random number generator of the PASCAL-compiler of the VAX-UNIX (Ultrix V2.2) at
-3-congruential generator, i.e.
with
a
=
62605,c
=
113218009 andm
=
536870912=
229• However, we discovered that this wasnot true. The actual generator was
with
a
= 1103515245 andm
= 2147483647 = 231_1. Xo is the initial seed, 0 <Xo <m,
and theith random number'i is Xilm. This value of m is prime so the sequence ('i)i~ 1 is periodic, and
for this value of
a
the random sequence has maximal period length,m
-1, becausea
isa
primitiveelement in GF(m). That means alll
-1 mod m
=
I, and ak mod m :1:1 for k = 1,2, ... ,m-2 [4].3. A Chi-square test
The first test we perfonned was a Chi-square test of the unifonn independent distribution of the
random numbers between 0 and 1. This intelVal was partitioned in 400 intelVals of equal length
(1/400) and for each intelVal i: [ (i - 1)/400, il400 )
Ii was detennined, where Ii is the number of
,/s, j=I,2, ... ,I00000, contained in intelVal i. The expected value Ii
=
250 and if the ~omnumbers are independent and uniformly distributed then
Ii is binomial distributed. Because Ii is
big enough (»5)
Ii
is about nonnally distributed with averageIi
=
250 and variance100000 x 1J400 X 399/400 ::::
t.
Then- 2
400 (Ji
-Ii)
'1.2 :=
'L---i-I
Ii
is about Chi-square distributed with 399 degrees of freedom [5]. The critical value of '1.;99 of a
1 %0 (I) unreliability test is about 491. The values of the tests were:
Xo 1 1234 236 528194
'1.2 2285 2141 119510 124351
So we can say that the random number generator is very bad. These results are so extremely
unlikely that we decided to look at the values of
Ii for X
0 = 528194 in detail. For this value of X 0~4-1295
i
972 649 ~ •• ~ • • • • • • • • • • • • • • m . -... ~-... ""'" ... --" ... - .. -~;. .. _ ... - .~ ... - .. ~ ... ,. _ ... '"---- .. _ .. -_ ... _ .... ~ .. + "4 ... .1' .. " ' - " . " _ _ •• - . _ ... - _ • • ~ .. _ _ _ _ _ ... _ _ - .. -.... ~-... _.",. - _ . _ - . - • • • • - - . I 400So this random number generator is definitely not random. 4. The spectral test
To get more insight in our random number generator, we apply the spectral test on it. According to D.E. Knuth [6] this is a very important test. He says about this test:
... not only do all good generators pass this test, all generators now known to be b~d
actually fail it. Thus it is by far the most powerfull test known, and it deserves
particu-lar attention."
The test detennines how random all points of t consecutive random numbers (rll,rll+l .... ,rll+l-l)
are distributed in [O,l]t. It does this by looking at parallel hyperplanes through all these points
and detennining the distance between these hyperplanes. Then the maximum distance is taken
over all sets of parallel hyperplanes that cover the points. For example, when t
=
2 and thegen-eratorisXj =7 XXj_l mod 11 andXo
=
I, then7 5 2 3 10 4 6 9 8 1 7 5
(ri)i~
1=
11'11'11'11'11'11'11'11'11'11'11'11""
...
•••.•• A'.,-...,
",
" , ••••• oIi. ,"
,~...,',
,
....
,
,
,
...
.. .,s....
,...
"
'
"
I •.••••• " , ···A ,,
,-
...
,
"
"
.... -p. ..
...•
,
.. ...'
" "
,
,
••• 1!f.
'
"
,
...•
'
" "
... . ..
o
o
1For t
=
2 the hyperplanes are lines. The dotted lines form one set of parallel lines and the dashedlines form another set (there are of course many other sets). The distance between the dotted lines is the maximum, so this is taken.
The smaller this maximum distance is, the better the distribution of the points in [0,1], is, and
thus the better the generator is. Let lIVt be that maximum distance.
We apply the spectral test for t
=
2,3,4,5,6, which is sufficient according to Knuth. The values ofthe Vt in our case (m
=
2147483647, a=
1103515245) are the followingt 2 3 4 5 6
Vt 45096.01 1413.21 197.25 67.79 35.50
Now what criterion do we use to determine whether a random number generator passes the spec-tral test or not? Knuth notes that this depends on the application and that it appears that in most
applications Vt ~ 2301t for t
=
2,3,4,5,6 will be quite adequate. The values of 2301t fort
=
2,3,4,5,6 are:t 2 3 4 5 6
2301t 32768 1024 181.02 64 32
Now we see that for our random number generator the inequalities hold, so our generator passes the spectral test!
For some purposes we would like a criterion that is relatively independant of m, so we can say
that a particular multiplier a is good or bad with respect to the set of all other multipliers for the
given m, without examining any others. According to Knuth [6, page 101] a reasonable figure of
merit for rating the goodness of a particular multiplier seems to be the volume of the ellipsoid in
-6-(
xlm -XZa - ... -x,a
t-l)l +X1 + ... 2+Xt ;;::
2.... V, 2This volume is
where
For our
a
andm
this givest 2
""
2.98x'12
v:
"" =
(t/2)!m
3 4 5.51 3.48 5 6 3.51 4.81Now Knuth says that the multiplier a passes the test if ~ ~ 0.1 for t
=
2.3.4,5.6 and it "passes with flying colors" if ~ ~ 1 for t=
2,3,4,5.6. So oura
passes this test very well!5. Conclusion
We have seen that the global behaviour of our random number generator is very good. but the local behaviour is extremely bad. Therefore we advise always to apply several tests to a random
number generator before using it. Further we advise to do also some simulations of situations for
which one can compute the results analytically, and compare the experimental values to the
theoretical values. This is also a test on the randomness of the generator.
If one wants to take an other random number generator. Park and Miller [7] have some nice suggestions (for example
m
=
231-1 anda
=
39373 ora
=
48271).[1] Kleinrock. L., Queueing Systems, vol. 1: Theory, John Wiley & Sons, New York, London,
Sydney, Toronto, 1975. pp. 94-99.
[2] Bratley, P .• Fox, B.L .• Schrage. L.E., A Guide To Simulation. 2nd Ed, Springer-Verlag inc.,
New York, 1987.
[3] Ultrix-32™ Supplementary Documents, vol. 2: Programmers, Digital Equipment
Corpora-tion, 1984, part 2: Languages, pp. 208.
[4] Biggs, N.L., Discrete Mathematics, Clarendon Press, Oxford, 1985, pp.344-353.
[5] Hogg, RV., Tanis, E.A.. Probability And Statisticalln/erence , Macmillan Publishing Co.
Inc., New York. 1977. pp. 329-358.
[6] Knuth, D.E., The Art Of Computer Programming, 2nd Ed., vol. 2: Seminumerical
Algo-rithms, Addison-Wesley, Reading, Massachusetts, 1981, pp. 89-110.
[7] Park, S.K., Miller, K. W., Random Number Generators: Good Ones Are Hard To Find,