Está en la página 1de 9

A Vectorized Long-Period Shift-Register Random Number Generator

Salvatore Filippone, Paolo Santangelo and Marcello Vitaletti

IBM European Center for Scientific and Engineering Computing


Via Giorgione 159, I-00147 Rome, Italy

Abstract Kc~wwd.~: Ixjng-pcrioti pseudo-randotn sequences,


linear-feedback shift-rcgistcrs, IRM 3090 Vector
A pseudo-random number generator, based on a Facility, In M R IS<:/~OOO.
lincar-feedback shift-register sequence, is presented.
The very long period of the generator, 2’279- 1 ,
Introduction
tnakcs it useful in modern statistical simulations where
the shorter period of other gcncrators could either bc
Most library routines for gcncrat.ing pseudo-random
exhausted during a single run or determine departures
numbers arc based on the linear congruential method,
from uniform randomness when generating positions
proposed by 1,chtner in 105I [ I]. With this method
in a tnultidimcnsional space. In particular, the pro-
each number is obtained from its predecessor, starting
posed generator ovcrcomcs the limitations of
from an initial .scciI .Yn, by the following recursive
tnultiplicative-congt-uential generators with modulus
formula
2”’ - 1 , which are widely used on computers with a
32-bit integer word size, such as the IBM S/370 family
of computers. (1) xi+1 = A.q + C ( mod M).

In this paper the propertics of Iincar-feedback shift- TXffcrent srqttenccs of integer random numbers are
register scquenccs are shortly rcviewcd and a sequence generated by starting with diffcrcnt values of the seed.
of order p = 1279 is proposed as a source of pseudo- I‘hc value of the modulus, M, is an upper limit for
randotn nutnbcrs. The production rule, by itself the period 1’ of the scqucncc, i.c. the number of con-
recursive, is efficiently vectorized on existing pipelincd sccu~ivc positions after which the scyuence is rcpcated.
vector processors, due to the large distance between if the constant (.T is zero the gcncrating recurrence is
the feedback positions and the positions to be gcner- called “tnuttipticativc-congrucntiat.” In this case the
atcd. The algorithm null scqucncc is produced when starting with a zero
may be implctncnted in
FORTRAN and may be easily ported on computers seed, while scqucnccs of rnaxitnal length P = M -1
with different word-lengths. 1Jsing a vectorized are producrd when siat-ting with any seed in the
IWR’I’RAN implementation of the algorithm on the interval [ 1,M- I] if M is a prime nutnbcr and A is a
113M 3090 tnodcl E Vector Facility, a rate of about primitive root of M [2].
6.5 million nortnalizcd random nutnbcrs per second
(Mrands) is achicvcci. A rate of about 3 Mrands is Implctncntitig an cficicnt pseudo-random number
obtained by an itnplcmcntation of the algorithm on gcncrator with a very large period using the recurrence
Ihe IUM RISC/6000 model 530. Simple statistical (I), hcncc ctnploping a lnrgc modulus M, is a difftcult
tests have shown the superiority of the proposed gcn- task, at least on computers using less than 64-bits for
erator with respect to the widely used multiplicative- infcgcr arithmetic, and this motivates the starch for
congruential gcncrator with modulus M = 23’ - 1 and altcrnativc production rules. In the following we try
tnultiplier A = 75 . to illustrate sotnc of the reasons why a very large
period P is n desirable propct-ty for a random number
generator.

‘I’hc first reason is that a single statistical simulation


may require more than I’ random numhcrs, For
cxatnplc, in ttic slntistioal sitnulation of spin-systems
CH2916-5/90/0000/0676/!$01 .OO0 tEEE 676
using MontcCarlo methods it is becoming increas- addition modulus 2 is cquivnlcnt to the logical
ingly common to see runs which use more than lOI* exclzoive-nr- operation:
random numbers. The period of multiplicative-
congruential generators with modulus P-1
M = 2”’ - 1 w 2 x IO”, which are widely used on com- (31 xl<= xkep + ~agqtLi mad(2).
puters supporting 32-bit integer arithmetic (like those i= I
of the IDM 370 family) is clearly insufficient for such
applications. It may be interesting to observe that the The USCof shift-register scqucnccs as pseudo-random
entire sequence of such generators can be produced in generators of binary digits was first proposed by
a few minutes by a vector processor like the IBM ‘I’hauswof-thc [ 51. A ncccssary condition for the
3090 Vector Facility. The second reason is that one period of the scqucncc to have the maximum possible
wants to minimize the effects of discretization (conti- value 2~- I is that the gcncrating polynomial
nuity error) when sampling a continuous variable in xp + xaix’+ 1 bc primilive (i.e., not factorable
the interval (0,l) by the set of real values W= xi/M mod(2) ). ‘I’h is condition is also sufficient when the
derived from sequence (I). The discretization effects maximal period 2~- I is itself prime (and hence p is a
are clearly minimized by choosing M close to the Mcrscnne cxponcnt). The simplest nont.rivial linear
maximum integer value allowed by the computer recurrcnccs modulus two LISC only two feedback posi-
arithmetic unit. A similar problem occurs when tions to gcneratc a new binary digit:
d-tuples of successive random numbers are used to
sample positions within the unit hypercube of a (4) xk = xk-,,@x&,, (p< q), k= 1,2, .. .
d-dimensional space [3]. In this case, the set of dis-
crete positions which may be represented by whcrc @ is the wc/zrsh~c-nr operation. ‘The recurrence
d-tuples, on a computer with an mbit word, is 2mxd,
(4) is associated to the gcncrating trinomials
while the number of distinct successor d -tuples xp + xq + 1 with p > 4 and gcncratcs a string of binary
which can be obtained from the sequence (1) is equal digits starting from a seed string, x..~, xm2,... , CC, , of p
to I’ = M - 1. On the other hand, for multiplicative- bits, not all zero. In the following WC will assume
congruential generators the values of M that can be that xp + xq + I is a primitive trinomial modulus two,
chosen are practically bounded by 2m in order to with p equal to a Merscnne exponent, so that the
perform the mod M operations efficiently on a com- period of the bit sequence (4) has the maximal length
puter with an mbit word. Therefore there are always 2!7--1.
at least 2mxd- 2mdiscrete positions which would never
be generated by such random sampling of the unit The USCof maximal-length scquenccs to gcnerat.e mbit
hypercube. Moreover, it is known that for some floating-point numbers has hccn discussed by several
values of A and d , the sparsity pattern of d-tuples authors [6] [7] [3]. ‘I‘hr most practical method for
from Ihe sequence (I) in the d-dimensional space is gcncrating a scqucncc of floating point numbers falling
far from being uniform [4]. in the open interval (0, I) is to assign the binary values
of 177linear rccurrcnccs with diffcrcnt initialization to
I’scudo-random generators with a long period, but not the rn bits contained in the computer word portion
necessarily employing a very large modulus, may be rcscrvcd for the mantissa. ‘l’hc 01 scqucnces may be
based on the general linear congruential method, of rcgardcd as dclnycd replicas, shifted by different
which the multiplicative-congrenlial is a particular offsets, of the same maximal-length scqucnce, for
case: example the scqucncc starting with a seed of all ones.
Obviously the inhit. computer words xk used to repre-
(2) Xk = apq+j + ... + apx+) + (7 mod(M). scnl. the floating-point numhcrs obey the same recur-
rcncc law (4), xr = xk ,,a~,, o, which requires the
The above sequences are periodic, MP being an upper initialization of a binary seed matrix with /?Ipbit rows.
bound for their cycle length. In the following we will In the next section it is shown that the scqucnce xk is
consider linear sequences with modulus M = 2 and guaranteed to satisfy some ncccssary conditions for
C= 0. In this case the only nonzero value that the ak statistical uniformity if the nz +it rows of the binary
coefficients may assume is 1, so that (2) reduces to an seed matrix arc Iincarly indcpcndcnt [S]. On most
additive-congruential generator, called linear-feedback computers the generating rccurrcncc may be imple-
shift-register, or linear rccurrcnce modulus two, whcrc mcnlcd very cflicicntly, since a single exxchtsive-or
each x,, may be rcprcscnted by a single hit and the computer instruction is nccdcd to advance one step
forward in pnrallcl ovcf a full word of m bits.

677
In the following section some arguments are given then holds for the cfcmcnts xh = x Atp if the sign of aff
which suggest the use a high-or&r linear-feedback indicts is rcverlrd.
shift-regist.cr as the base of an algorithm for generating
pseudo-random floating-point numhcrs. Some per- ‘I‘hc l&it seed IV” of a maximal-fcngth scquencc may
formnncc data obtained with a FORTRAN impfe- bc reprcscntcd as a binary row vector and the effect of
mentation of the algorithm on the If3M 3090 Vector advancing k steps in the shift-rcgistcr sequence may bc
Facility and on the IBM RISC/6000 are discussed in described as the result of applying k times a linear
the third section. The results of some statistical tests, p x r matrix operator C, from the right, to w”, i.e.:
which demonstrate the quality of the generator, are
rcportcd in the last section. (6) ,$ zz w”,k , .

The cocff~cients of the matrix operator C are deter-


A long period shift-register random
mined by lhe shift-rcgistcr recurrence parameters p
number generator and q:
A table of primitive trinomials whose degree is a
Mersenne exponent has been published by Zierler [9] Jc+l = \p,p, _._w;y,wy>= wkC
(
and it has hccn reproduced by Bright and Enison [7].
= (w!, w:, . . . w;, w:ow:+q)
A partial reproduction of the Zierfer fist of primitive
trinotniafs, only including trinomials of order greater
than 1000, is given in Table 1. A scqucncc of uniformly distributed floating-point
numbers with an nIbit mantissa can be built in a com-
putationalfy cfftcicnt way by using m diffcrcnt
Table 1. Primitive trinomials w~msc degree is a scqucnccs such as (4), each d&et-mining the value of
Mcrscnnc exponent. one binary digit of the mantissa. In this cast the m
sequcnccs may bc advanced simultaneously by exe-
Ordinal IIcgrcc 4 for which xp + x9 + 1 is cuting a single excIusI’~~c-0~computer instruction.
irreducible IJsing the fatter approach one has to specify a seed
I5 I279 216, 418 binary matrix W” with m rows and p columns. The
mbit columns of the seed matrix W0 contain the frost p
I6 2203 None
clcmcnts x1,x2, ... , x, of the scqucnce. It has already
16 2203 None been observed that any mbit column xk as a whole
obeys the same rccurrcncc law of any of its individual
17 2281 715, 915, I029
binary digit.s, i.c. xk = x/, ,,@xh ‘I , so that (6) afS6
18 3217 67, 576 appfics to the tr;lnsformntiorIs of the seed matrix W” ,
i *e. \Vh = \V”<‘k
, .
19 4253 NWtf?
20 4423 271, 369, 370, 649, It is clear that all the possihlc 2”’ binary configurations
-
139.3, 1419, 2098 of r?zbits should occur cquaffy often in the sequence
of l?rbit worJs {x} if they arc to bc used as a source of
21 9689 84, 471, I8.36, uniformly tfislrihutcd pseudo-random numbers. This
-.
2444, 4187 basic prc-rcqllisitc is actually satisfied if the m pbit
- rows (1~1511)of the scrtl matrix W” arc line&j! inde-
pendent; as stntcd by the following theorem [7]:

All the fincar-feedback shift-rcgistcrs xk = xk P@xk q , IA {x} br thr shift-rcpistcr SC~IICIICC of pbit column
associated with trinomials listed in the above table, vectors associated to a primitive trinomial of dcgrcc p.
product maximal-fcngth scqucnccs. 7’hc cnr@<~atc I,ct W’) hc tfw sctd matrix. If W” is nonsingular, each
.%?quctzce.uk= xh p@x,<,,,,, associatcd to a shift-register of the 2p - I nonzcro cofunin vectors occurs exactly
also has maximal fcngth. This is easily checkctf by once during one period of the scqocnce, and conversely.
observing that the production rule may be revcrtcd licncc, if fy) is a shift-rcgistcr sequence of m bit
and that the conjugate scqucnce is the revcrsc of the colmnn vectors, m < p, and the m p bit rows of the
original sequcncc if the seed is also revcrtcd. InJced, srcd matrix arc linearly indcpendcnt, then all nonzcro
from .xX= xa ,,@x.., it follows that xr. p = xA@xA s , colrml~~ vrctors occur cqaalfy oftal and the all-zero
since (x@y)@.v = x. The conjugate recurrence law colr~im vcctor occurs one time Icss.

678
From the maximal-length property of the sequence it computers hecomcs possihlc when the shifts relative
follows that all the nonzero pbit binary configurations to both t.hc feedback positions arc larger than the
occur once and only once along the entire sequence computer vector rcgistcr size. For example, the shift-
{w} because C” # C” for any pair of integers A, p register scqucnce xk = xk ,z&xk .IOh3,which is the con-
falling in the interval [I ,2p-11 and such that A# cc. jugate scqucncc associated to the trinomial
x’2’9 + xl’6 + 1 , may bc implcmcnted to fully exploit
Diffcrcnt recipes have been proposed by several the vector hardware of supcrcomputers with up to
authors to enforce the linear indepcndcnce of the seed 1024 vector rcgistcr clcmcnts.
matrix rows without introducing strong disuniform-
itics in the seed binary pattern. I,cwis and Payne [6) All the hut&n associated to the rcgulariaation of the
suggested the use of dclaycd replicas of the basic seed may bc eliminated, when using a generating
recurrence (4), starting from a p bit seed of all ones, to trinomial with a large dcgrec, since the probability of
initialize the m columns of the seed matrix W”. In generating a pseudo-random seed matrix with linearly
this case, the “dumping” of the strong seed regularity, dcpcnclcnt rows bccomcs negligible. In fact, it may be
which is inhcrcnt in having a first column of all ones, observed that when m is greater than one the number
is obtained by performing a large number of steps as of different maximal-length scqucnces {x} is much
part of the initialization procedure. Another simple larger than 2~- I, being cquat to the number of all
procedure, suggested by Kirkpatrick and Stall [3], possible linearly indcpcndcnt sets of m pbit vectors
employs a standard multiplicative-congential gcner- which can be used as the initial seed W”. When rnep
ator for the random initialization of the seed matrix, this number is of t.hc order of 2,nxp. The initialization
followed by a rcgularization that guarantees the linear procedure should not cnforcc the linear independence
independence of the rows. Also in this case the of the seed rows, bccausc the probability that a linear
rcgularization requires some care to avoid disuniform- depcndencc would occur when generating a m x 1279
ities of the seed binary pattern. binary seed matrix for the shift-register sequence
xk = xk- 1279@~k1o63is cnsily cstimatcd to bc less than
A great advantage of the crocedure proposed by 2m- 1279
9 and thercforc it is absolutely negligible for any
Kirkpatrick and Stall is that many diffcrcnt sequences reasonable value of the word size m .
may be generat.cd by specifying different values of a
scalar seed. It is important that this initialization pro- A very simple procedure for the initialization of the
cedurc be clearly and fully specified in order to seed matrix may be implemcntcd in FORTRAN and
compare the results obtained with different implemen- it may bc easily adapted to any computer in which
tations of a shift-rcgistcr algorithm. Indcecl, the algo- intcgcr arithmetic opcrdions arc pcrformcd on words
rithm itself is suitable to produce idcntica! numbers on of at lcast 32 bits and in which the floating-point
different computers using the same number of bits for mantissa contains up to 64 binary digits. The proce-
the floating-point mantissa. In the general case of dif- durc cmploycs the multiplirativc congrucntial gcner-
fercnt computers using mantissas of diffcrcnt length, ator with modulus 2”’ - 1 and multiplier A = 75 to
the differences could still be forced to appear only in simulate F x m “coin-tossing” cvcnts which determine
the least significant bits of the larger floating-point the random initialization of the p x m seed matrix.
word when consistent procedures arc employed for the The m x p bits of the seed matrix arc initial&d, pro-
initialization of the seed. Therefore, a standardization cccding in column-major order, to 0 or 1 depending
of the initializntion procedure may offer great advan- on the value of the random number produced by the
tagcs in terms of portability, making it possible to auxiliary gcncrator. l‘his initialization procedure guar-
rcproducc the results of a statistical simulation on dif- antccs that the most significant binary digits of the
fcrcnt computers. mantissa rcprescnting the k - th random number in
the scqucnccs obtained on two different computers
Cotnpagncr and I Ioogland [X] have recently analyzed with diffcrcnt mantissa lengths arc identical if both
the properties of the correlation functions of any order scqucnccs arc initial&d with the same scalar seed.
for maximal-length shift-register binary sequences. IJsing the above initialization strategy, identical
‘I’heir findings support the somehow intuitive statc- results, except for the last bit, arc obtained in single
mcnt that longer scqucnces, which are associated to precision on the IBM S/370 with a 24 bits mantissa
high dcgrcc gcncrating trinomials, have better random- and on the IRM RlSC/6000, with a 23 bits mantissa
ness propcrtics. An additional reason for using high (conforming to the ll?F,IY 754 standard where the
dcgrcc generating trinomials is that an efficient imple- most. significant bit is hidden).
tncntation of the shift-rcgistcr algorithm on vector

679
Vecforization of the shift-register Vector Facility the normalization takes about 30% of
the total time required to gcncrate a normalized
algorithm random number when using a highly tuned assembly
language implcmcntation of the algorithm, while it
The shift-register generator with p = 1279 and q = 2 16
takes about one half of the total time when using the
was implemented in FORTRAN on the IBM 3090 vectorizcd I;C)R’l’RAN code. As a result, the normal-
Vector Facility. The conjugate production rule has ized IY’IR7’RAN code products about 6.5 millions of
been adopted in order to get the maximum efftciency 32 bit normalized floating point numbers per second,
on pipelined vector computers with very long vector
while the production rate of unnormalized numbers is
registers. Apart from details concerning the exponent
about twice as large. ‘I’ablc 2 illustrates the peak pcr-
setting and normalization of the floating-point words
formance of the algorithm, measured in Mrands
receiving the generated random numbers, the (millions of pseudo-random values generated per
FORTRAN code kcrncl is very simple: second), for single and double precision, on the IBM
3090 model 6OOr-3 with a clock-period of 17.2
..... nanoseconds and on the IIJM RISC/6000 model 530
DO 1 K= . . . . with a clock-period of 40 nanoseconds. The pcrform-
..... ancc actually depends on the number N of pseudo-
X(K) = IEOR(X(K-P),X(K-P+Q)) random values to bc gcncrated in a single subroutine
.....
call, and the penk performance is approached when N
1 CONTINUE
becomes larger than the seed length p = 1279.
Ilowever, with a careful implementation it is possible
to achicvc a very good performance, on average, also
Although the above FORTRAN loop defines a
when the subroutine is consecutively calicd several
recursion it is easy to recognize that I consecutive itcr-
times with rctatively small values of N.
ations could be safely exccutcd in parallel, between
two synchronization steps, provided that the offsets p
and p - q of the feedback positions, with respect to
the position being generated, are larger than or equal T’able 2. Pcrformancc of the FORTRAN subroutines.
to I. Therefore, the loop can be vectorized on pipe- Precision Computer Mrands
lined vector-register computers with vector-size up to
p - q and also on pipelined architectures without
vector-registers, provided that the maximum length of
the pipeline, i.e. the maximum number of different
consecutive elements of the sequence being tempo-
rarily allocated within the pipeline, does not exceed
p- q. The choice that has been made for p and q is
such that up to 1063 new elements could be generated
in parallel between two synchronization steps (it may
be observed that on a vector processor this synchroni- Statistical tests
zation does not require any programming effort, as
The ability to reproduce the results of a statistical sim-
this is inherent in the completion of the vector
ulation is the main advantage of using dctcrministic
instruction).
computer algorithms for gcncmting pseudo-random
numbers. Pacudo-random number generators are
Different versions of the code may be used to
therefore cxtrcmcly useful in many diffcrcnt applica-
produced normalized and unnormalized numbers.
tion arcas like optimization theory and statistical
The USCof unnormalizcd floating point operands is
physics. At the same time, the pseudo-random
not allowed in S/370 multiply and divide vector
numbers gcncratcd by such algorithms may show
instructions. Nonetheless in many statistical simu-
departures from true randomness clue to the regularity
lations the random data are not involved in multipli-
intrinsic in the generating procedure.
cations but rather in compare type instructions for
which normalized and unnormalized formats can be
Assessing the statistical properties of a pseudo-random
equivalently used. A random number generator which
source is usually a diflicult task which may be
produces normal&d floating point numbers is usually
achieved by two complcmcntaly approaches. The
slower because the normalization is an extra operation
first approach uses empirical tests to compare the frc-
performed on data which have ahcady been generated
qucncy of occurrcncc of some pseudo-random events
in the unnormalized format. On the IBM 3090
680
with the probability of their occurrence computed on overlapping scgmcnts of Icngth d of the scqucnce, i.e.
the basis of an assumed theoretical distribution. In SIk= (XCkI)Xdl1, ... , XkXd) , thus requiring d x n numbers
the second approach one tries to derive the more rele- for sampling II positions.
vant parameters of the statistical distribution of the
pseudo-random values based on the actual form of the
generating algorithm. An example of the latter
approach in the investigation of maximal-length shift-
register sequences is found in the previously men-
tioned work of Compagncr and IIoogland [Q. Their
analysis shows that the relative number of correlation
functions of any order of a maximal length shift-
register sequence of order p that show a nonrandom I ,atticc dimension
behavior decreases as 2--p+They also report the results
of some empirical tests for the sequence with
t.p, q) = (1279,216) , upon which the present generator
is based, which show only very small deviations from
statistical uniformity in the observed distribution of
the binary digits.

In the following we illustrate the results of some sta-


tistical tests of the pseudo-random floating-point
number generator implemented on the basis of the
sequence with 6, q) = (1279,216) . The numerical 1atticc dimension
experiments were aimed at testing few of the lowest
order moments of the distribution. Very long series of
random events (up to 5 x 64 millions for the
5 -dimensional equidistribution test) were generated
in order to compare the shift-register generator against.
the multiplicative-congruential generator with
M = 231- 1 and A = 75, which is widely used on
32-bits computers. In several experiments the latter
generator showed departures from a truly random
uniform distribution as the length of the sample size Ilypcrcubcs with dimension ranging from 1 to 5, and
exceeds 8 x 10”, while the shift-register generator wilh, rcsprciively, (2’“)’ , (2”)2 , (2s)1 , (24)4 and (2Ry
produced acceptable results in most of the exper- lattice sites. wcrc used in the uniformity tests. Three
iments. sets of cxpcrimcnts wcrc run for each lattice by sam-
pling rcspcctivcly, I Y 22n, X x 22n , and 64 x 22nposi-
The empirical tests which have been sclcctcd to check tions of the 1atticc. For the above mentioned lengths
the gcncrators arc the following simple ones: of the sample, the cxpcctcd number of cvcnts per ccl1
1. d-dimensional cquidistribution test (up to 5 (occupancy numhcr) is, respectively, 16, 128 and
1024 for the I - , 2 -. and 4 -dimensional lattices,
dimensions),
and twice as large for the 3 - and 5 -dimensional
2. Maximum oft test, lattices. The chi-.rquar-cdstatistical test was applied to
each cxpcrimcnt hy computing the variable
3. Run length test.

‘I’hc first test is meant to discover deviations from uni-


formity in the distribution of d -tuples in a
d-dimensional lattice. Sampling positions in a
d-dimensional lattice requires to use the linear
pseudo-random sequcncc to form d-tuples. The were h are the observed occupancy numbers and l is
easiest method is to form d-tuples Zk by the d con- their cxpccted value for each of the n sites of the
secutive numbers starting from xk, i.e.: lattice. Due to the rclativcly Iargc values of i in all the
j?k= (Xk, .. . , xkc,, ,) . Another method, which is com- above mcntioncd tests, the values of the empirical var-
putationally more expensive, uses contiguous non- iable jii arc cxpcctcd to closely follow the distribution
681
of the x: variable with v = (n - 1) degrees of freedom. d - tuplcs), cvcn when sampling a d -dimensional
Moreover, due to the large value of v, j;$ closely lattice by consecutive partially overlapped d -tuples,
approaches a normal distribution and the result of as shown in I’ablc 4.
each cxperimcnt may be usefully represented by the
value of the normalized statisi.ical control variable The above results, which arc particulaT\y bad for the
n = (x2 - v)/Jr v with zero mean and unit variance. multiplicative-congruruential gcncrator were partially
Each experiment has been repeated N times (N= 40). expcctcd, since the size of thr largest samples was an
‘I‘hc rcsuits are reported in ‘Tables 3 and 4 where the apprcciablc fraction of the entire period. I Iowever,
quantity b = C/( l/n) is given for each set of exper- the results are also affcctcd by the dimensions of the
iments. Assuming the equidistribution of the sampled lattice. This was demonstrated by repeating the 1 - ,
pseudo-random numbers, the above considerations 2 -, and 3 -dimensional uniformity tests on (K6)’ ,
imply that h itself is normally distributed and the (K3)2 , and (K2)3 Jattices, with K = S and K = 7. The
widely accepted 3 CT rule can thus be exploited to results for K = 5 are listed in ‘Table 5, while those for
single out anomalous results. K = 7 are listed in ‘l’ablc 6.

‘l‘ahle 4. N-dimensional cquidist.rihution kst. Conscc- ‘I’ahlc 5. N-dimensional equidistrihution test. Conscc-
ul.ivc, partially overlapped, d-tuplcs. Values utivc, partially overlapped, d-tuplcs. Values
of the control variable b. of Ihc control variable h.
A) Muttiplicativc-congrucntiat gcncrator. A) Multipticativc-congrucntial generator.
- .-
Satnplc size
J,attice dimension
Sample I ,attice dimension (No= 5”x 16)
size
1 2 3
1 2 3 4 5
Nox 1 1.o -1.1 0.4
1 x 22” 1.4 2.3 0.2 -1.4 1.9 Nox 8 -2.5 3.1 -2.7
8 x 220 -4.9 4.3 -2.9 -4.x -4.1
Nox64 -1.5 1.2 -0.2
64 x 220 -35. 24. -23. -37. -24.
R) Shift-register gcncrator.
J!l) Shift-register generator.

1
S;\mplc size
J,atticc dimension
(No= 5”x 16)
Sample 1atticc dimension 2 3
size .--
No x-.-__
1 1.5 1.X 3.6
1 2 3 4 5 --- --_
1 x 22”
8 x 22”
64 x 22”
0.0
I.7
0.4
-0.4
-0.2
0.2
-0.2
-3.3
-1.1
-0.1
-0.9
-0.9
I.1
-0.2
-0.7
-7
-~_-
Nox 8
---.
No x 64
--
------
-1.0
3.0
-0.7
-1.5 -1.9
2.4

It is sccn that the muliipticativc-congrucntial generator


products acccptahlc rcsutts on the first scrics of tests (
It is clearly seen how the standard multiplicative- K = S), while the results on the second scrics ( K = 7)
congrucntial random nutnber generator fails even for arc clearly rmncccptahlc (only consecutive overlapping
moderately tong sequences, of the order of 8 x JO” d-tuplcs wcrc used in those tests). Only in few
numbers, as shown by the large absolute values cases, in both scrics of tests, the results produced by
assutncd by the statistical control variable. On the the shift-rcgistcr gcncrator dcviatcd significantly from
other hand, the shift-register generator performed well the values cxpcctcd from a true random source.
up to the longest considcrcd scquenccs (54 x 10”

682
and finally followed by a last run of length 3 (1, 4, 5).
Thcsc arc caiiccl runs down and similarly one could
‘I‘ahlc 6. N-dirncnsional equidistribution test. Conscc-
ntive, partially overlapped, d-tupks. Values analyst runs up which are simply obtained by
of the control variable b. changing the inequality sign. It is not possible to
apply directly the 12 test to run lengths because of the
A) Multiplicative-congrcntiai generator. dependency of the consccutivc runs and more eiabo-
Sample size rate tests should hc applied (see, c.g. [2])+ On the
I Atice dimension other hand Knuth [2] suggests to simplify the
(No= 7”x 16)
problem, again using the x2 test, but “after throwing
I 2 3
away the elcmcnt which immecliatcly follows a run, so
Ni,x 1 -3.5 -3.8 -6.6 that when Xj is greater than Xj+l the new test is
started with &,2 and the run lengths are independent.
No x 8 -4.3 -9.1 -12.
Now the x2 can be applied and the probability of a
N,,x 64 -22. -25. -30. run of length r is easily shown to be i/r! - i/(r+ l)!
I3) Shift-register generator. [2]. This test has been applied to three large (- lo”,
- 8 x 10” , and - 64 x IO” ) vectors of random
Sample size numbers by allowing the recognition of runs down, up
Lattice dimension
(N,, = 7” x 16) to the improbable length 8 plus the tail of the distrib-
1 2 3 ution function. As in all previous cases all tests have
been repeated 40 times to strengthen the statistics.
Nox 1 0.5 -5.2 2.0 The run length tests wcrc passed well by both genera-
No x 8 2.7 -2.9 2.5 tors.

N,,x 64 7.3 -0.6 0.1


Tahlc 7. Maximum of I test. Values of the control var-
iable b.
‘l’hc maximum of t test is obtained by generating
A) Multiplicative-congrcntial gcncrator.
random vectors, each containing t random numbers,
such as I/= (X,, X,, .... A’,) and selecting the maximum
component of the vector I/; this value can be easily Sample Value of t
shown to obey the distribution function I(x) = x’ so size
that a x2 uniformity test can be applied again as in the
previous case. The results arc shown in Table 7
where number of random t-dimensional sampled
vectors are N 64 x 10” and w iOh rcspcctivciy, and the
sampling interval for the x2 test is l/4096; again the
calculations arc rcpcated 40 times to strcngthcn the 13) Shift-rcpistcr gencmtor.
statistics and the quantity rcprescnted is h as in the
previous tables. As for the simple uniformity tests,
the shift-rcgistcr generator proved to be superior, since
it did not product unreasonably large values ( failing
outside the ( -30, + ST) interval) of the control vari-
--__
.--1
__.-.--
2
Value of t

3 4 8
able 0. The results for intcrmediatc values oft arc not -0.1 2.7 -0.4 1.1 1.1
shown because they only reline a tendency already
shown by the table; same results are obtained for the -2.0 0.8 1.3 0.8 1.5
minimum oft.

The last test used to check the generator is the run


lct1gth test. This consists in obtaining the statistical Conclusions
distribution of the length of contiguous monotone
subscquenccs, that is vectors of random nutnbers The results obtained on the above simple tests with
I/=(X, x,, .-., x,) obeying the condition the proposed shift-register pseudo-random number
x, 2 x2 I ... < x,,. For example, the sequence generator with period 212’9- 1 arc rather encouraging,
3, 4, 7, 9, 3, 2, I, 4, 5 contains a run of icngth 4 ( since in most of the tests the gcncrator approached
3,4,7, 9) followed by two runs of length 1 (3 and 2) better than a muitipiicativc-congruentiai generator the
683
behavior of a true random source of uniformly distrib- [3] S. Kirkpatrick, lT.1’. Stoll, A Very Fast Shift-
uted numbers. Indeed, the tests showed that the mul- Rrgisfcr Scqucncc R~I~~II~ Number Gcncrator
tiplicativc congruential generator cannot be safely used ./ournal of Computcltioncll Physics, Vol. 40,
when the size of the sample is an appreciable fraction 517-526, 1981.
of the entire period. More experiments shouJd be
[4] G. Marsaglia, Ranclor~~ numbers fall mainly on
done, e.g. using the shift-register generator on statis-
the plants, Pr-OC. NOI. Acod. Sci., Vol. 61, 1,
tical simulation problems for which reference data arc
available, in order to exclude that the regularities 1968.
inhcrcnt in a particular problem may interfere with the [SJ R.C. ‘l‘ausworthc, RRI~OIII numbers gcncratcd
correlations intrinsic in the generating procedure. The by linear rccurrcncc r~~odulus two, Mathematical
shift-register generator is vectotizable and may efft- Comptling. Vol. 19, 1965.
ciently exploit the hardware of pipelined supercom-
putcrs and workstations. The proposed initialization [6] T.G. I,ewis and W.11. Payne, Gcncralixcd Fecd-
back Shift Rcgistcr l’scudorandom Number
procedure helps in making statistical simulations
Algorithm, .lournctl of I/X Association
for Com-
reproducible on different hardware platforms.
puting Machinery, Vol. 20, No. 3, .July 1973.
[7] J1.S. Bright, R.J,. Jrnison,
Quasi/Random
Bibliography Number Scquenccs from a Long-Period ‘I’IB
[I] D.11. I,ehmer, Mathematical methods in largc- Gcncrator with Remarks on Application to
scale computing units, Ann. Cumput. Lab. Cryptography, Computing SWV~U, Vol. 11, No.
~~arvurd I/., Vol. 26, pp.l41-146, 1951. 4, Dcccinhcr 1979.
[2] D.JT. Knuth, The Art of Computer Program- L-81 A. Compa#lcr and A. Iloogland, Maximum-
ming, Addi.ron- Wesley, Reading Mcxr., Vol. 2, Length Scqucnccs, Cellular Automata and
1969. Random Numbers,./ournal of Computational
Physics, Vol. 71, 391-428, 1987.
[9] N. Zicrlcr, Primitive trinomials whose degree is a
Merscnne exponent, Information and Control,
Vol. 15, 67-69, 1969.

También podría gustarte