Sie sind auf Seite 1von 9

ISSN 20700482, Mathematical Models and Computer Simulations, 2011, Vol. 3, No. 6, pp. 697705. Pleiades Publishing, Ltd.

., 2011.
Original Russian Text E.A. Tsvetkov, 2011, published in Matematicheskoe Modelirovanie, 2011, Vol. 23, No. 5, pp. 8194.
697
1. INTRODUCTION
Computations performed by the Monte Carlo method rely on random number sequences. On comput
ers, random numbers are replaced by pseudorandom numbers produced by software pseudorandom num
ber generators (PRNGs). Since a sequence of pseudorandom numbers is deterministic, this raises the
question whether one can use these numbers as random. In order to answer it, we can approach the prob
lem either theoretically or empirically.
In most cases, the theoretical study of PRNG involves determining its period and proving that the gen
erated random numbers are uniformly distributed on the period. Such studies are given, for instance, in
[1], for linear congruential generators and in [2] for the Mersenne Twister generator. These and many
other works treat uniformity as PRNG, going through all its possible states once within a period. It is sel
dom that the whole period is attained in practical applications. For instance, the period of the Mersenne
Twister generator proposed in [2] is the Mersenne prime . In most cases, the statistical properties
of a short, compared, whole period, part of the sequence are not considered.
Empirical tests imply statistical properties of sequences tested experimentally on a computer. Gener
ally, this is done by checking the background hypothesis , which states that the sequence of PRNG out
puts is a sequence of independent realizations of a random variable uniformly distributed on the segment
[0, 1]. Sometimes one can state the competing hypothesis and propose a criterion to see which one is
true: or .
At present, there are several libraries of software tests [35] to check the background hypothesis against
several competing hypotheses. The choice of competing hypotheses depends on theoretical studies of
behavior of different PRNGs held at the time the test library was formed or on regularities found in them.
Clustering of random points or whether they fall into the hyper plane [6] can serve as an example of a com
peting hypothesis.
The fact that the generator has passed all tests of a set does not necessarily mean that the sequence it
produces can be treated as random and used in any Monte Carlo algorithms. The problem of testing
PRNG should be treated as finding out whether the sequence of a fortiori nonrandom numbers can be
used to solve a particular practical problem or class of problems, while it may be impractical for other
problems. The best case is when PRNG is tested on a similar problem with the known solution.
In this work, we test the chosen generators for uniform distribution on a hypercube. This test is imple
mented in many previous works. However, new computational resources allow repeating it with new
parameters that set the dimension and the number of partitions of the hypercube. In this work, we perform
tests up to the dimension of inclusive. We choose generators used in many projects for radiation
propagation simulated by the Monte Carlo method.
19937
2 1
0
H
1
H
0
H
1
H
15 k =
Empirical Tests for Statistical Properties of Some
Pseudorandom Number Generators
E. A. Tsvetkov
Moscow Institute of Physics and Technology, Institutskii per. 9, Dolgoprudny, Moskovskaya oblast, 141700 Russia
email: tsvetkov_egor@mail.ru
Received May 20, 2010
AbstractStatistical properties of software pseudorandom number generators are tested based on uni
form distribution on a unit hypercube with dimensions from 1 to 15. Some CLHEP generators, the
Mersenne Twister generator and the MCNP generator, are tested. Parts of the pseudorandom number
sequences with poor statistical properties are found. Easytorectify flaws of two CLHEP generators are
detected.
Keywords: tests for pseudorandom number generators, Monte Carlo method.
DOI: 10.1134/S207004821106010X
698
MATHEMATICAL MODELS AND COMPUTER SIMULATIONS Vol. 3 No. 6 2011
TSVETKOV
2. METHOD OF EMPIRICAL TESTING
One can find a constructive dimension for many algorithms operating by the Monte Carlo method [7].
The constructive dimension, , of the algorithm is the number of random values used by the algorithm for
one statistical test. To simplify the subsequent reasoning, we consider the problem of calculating a multi
ple integral over the set
by the Monte Carlo method by the formula
, (1)
, (2)
where is the sequence of kdimensional random vectors uniformly distributed inside . Suppose the
set is a kdimensional unit hypercube. The constructive dimension of the algorithm that calculates
by formula (2) is k.
In most cases, the kdimensional vectors are formed of a sequence of pseudorandom numbers ,
as follows
, , , , . (3)
In [8], for an arbitrary sequence of numbers , the concept of kiuniformity (the letter i stands
for independently to single this method out from other methods that produce random vectors) is intro
duced to form the vectors by formula (3). If condition (1) is met, the initial sequence is called ki
independent and can be used to solve problems with the constructive dimension k.
It is proved theoretically that the sequence of independent realizations of a uniformly distributed
random variable is kiuniform for any k (to put it more strictly, condition (1) is seen as follows: the
sequence converges almost surely to I). However, the intuitive properties of random sequences cannot
be transferred to sequences of pseudorandom numbers. For instance, some PRNG that passed the test for
1uniformity fail to do so as early as for the dimension of 2 [1].
No empirical test can show whether a sequence is truly kiuniform, as empirical tests use parts of
sequences of bounded length while the very property of kiuniformity is an asymptotic characteristic of
the sequence. Empirical tests can establish properties only of a bounded part of a sequence of numbers.
Thus, an empirical test for kiuniformity should be held for each dimension k separately. We should
test the part of the sequence to be used to solve the practical problem.
In order to apply the tools of mathematical statistics, we need to consider the sequence generated by
PRNG as the sequence of implementations of the random kdimensional variable; however, we need to
be cautious in stating the background hypothesis and choosing a method to test it, keeping in mind that
the purpose of the work is to see whether a sequence of pseudorandom numbers can be used to solve prac
tical problems. Given the above reasoning, we take the statement that the random kdimensional variable,
with being the sequence of its sequential realizations, has the probability density uniformly distributed
inside the hypercube as the hypothesis to be tested.
As we stated in the introduction, in order to test the background hypothesis, we use the test for uniform
distribution on the hypercube. To do this, we partition the kdimensional unit hypercube into cells and
calculate the number of hits into each cell. In order to estimate the probability of the results, we use the
criterion. We describe this algorithm more strictly below.
Not every Monte Carlo method allows setting the dimension k. When we simulate trajectories of par
ticles with absorption, we cannot beforehand set the number of collisions the particle experiences before
it is absorbed. Hence, the number of random values used to simulate the trajectory of one particle is ran
dom. Given the way random numbers are used in MCNP [9], we can set the constructive dimension K
(also called the track length). To simulate the trajectory of the nth particle, MCNP uses random numbers
starting from , where K is 152 917 by default, . If it took more than K random numbers to
simulate the history of one particle, MCNP displays the message that the number K should be increased,
without any interruption of computations. If it was less than K numbers, the rest of the numbers are cast
k
k
E
( )
k
E
I f d =

r r
lim
n
n
I S

=
( )
1
n
n i
i
V
S f
n
=
=

r
{ }
i
r
k
E
k
E
n
S
{ }
i
r { }
i
x
[ ] 0,1
i
x
( )
1 1 2
, ,...,
k
x x x = r ( )
2 1 2 2
, ,...,
k k k
x x x
+ +
= r
( ) ( )
( )
1 1 1 2
, ,...,
n n k n k n k
x x x
+ +
= r
{ }
i
x
{ }
i
x
{ }
i
x
{ }
n
S
{ }
i
r
k
E
0
H
k
S
2

K n 0,1,... n =
MATHEMATICAL MODELS AND COMPUTER SIMULATIONS Vol. 3 No. 6 2011
EMPIRICAL TESTS FOR STATISTICAL PROPERTIES 699
away. Thus, the constructive dimension in MCNP is 152 917 by default. In this work, in order to test the
MCNP generator, in addition to (3), we formed the random vectors in a different way, viz.
, , , , , (4)
where k stands for the dimension of the vectors and K is the constructive dimension of the MCNP algo
rithm.
3. ALGORITHM OF THE EMPIRICAL TEST
Although the test for uniform distribution of the points on a hypercube was described by many authors,
we state its algorithm once again to eliminate ambiguity. Suppose PRNG generates real numbers in the
semiinterval . We divide each edge of the unit hypercube into S similar intervals, partitioning the
entire hypercube into cells, where k is the dimension of the hypercube. We set the boundaries of the sth
interval as follows
.
We assign the numbers from 1 to to the resulting cells.
Suppose is the sequence of random vectors obtained from PRNG outputs, setting the points in the
kdimensional space. Taking the first M vectors from this sequence, we calculate how many points fall
within each cell of the hypercube. Suppose is the number of hits in the cell with the number i,
. We use MX to denote the mathematical expectation of the variable , which is the same for
all cells and is
.
We use the criterion to test the background hypothesis. We calculate by the formula
. (5)
Setting the confidence level, we can make a decision on whether the initial data contradict the hypoth
esis we are testing.
4. CHOOSING RANDOM NUMBER GENERATORS
We found generators from common software used to compute radiation transfer by the Monte Carlo method
most interesting. First of all, these include GEANT that uses CLHEP to generate random numbers [10].
CLHEP includes 12 random number generators that produce numbers in the range . All random
number generators are represented as C++ classes. In this work, Hurd160Engine, Hurd288Engine,
JamesRandom, MTwistEngine, RanecuEngine, RanluxEngine, Ranlux64Engine, RanshiEngine, Trip
leRand, and DualRand were the CLHEP generators we tested. HepDrand48 and RandEngine generators
also included in this library were not tested since they use the standard C library generator that has a poor
reputation. All CLHEP generators except Hurd160Engine and JamesRandom passed the DIEHARD
tests described in [3]. The Hurd160Engine and JamesRandom generators failed the DIEHARD Minimum
Distance test.
The memberfunction flat() of the corresponding class of the generator was called to obtain random
numbers. This function returns a doubleprecision pseudorandom number. For the initial state, we take
the state of the generator after its constructor is called without parameters. If the state depends on the
number of already created replicas of the generator, we consider the state of only the first replica (after the
constructor is called for the first time).
In this work, we also tested the linear congruential MCNP generator [9]. Its adequacy is justified by the
great number of practical problems solved.
The known Mersenne Twister generator [2] was tested in three variants, including the one stored in
CLHEP. The second variant corresponds to the code proposed by the authors of this generator [12] (file
mt19937ar.c). The third variant corresponds to the generator used in MATLAB after the function
rand('twister',5489) is called that sets the type of the generator and its initial state [11]. The MAT
LAB version of the generator and the original version differ only by the setting of the initial state of the
( )
1 1 2
, ,...,
k
x x x = r ( )
2 1 2
, ,...,
K K K k
x x x
+ + +
= r
( ) ( ) ( )
( )
1 1 1 2 1
, ,...,
n n K n K n K k
x x x
+ + +
= r
i
r
[ ) 0,1
k
S
)
1
,
s
s s
S S

=

k
S
{ }
i
r
i
X
1,...,
k
i S =
i
X
k
M
MX
S
=
2

( )
2 2
1
1
k
S
i
i
X MX
MX
=
=

( ) 0,1
700
MATHEMATICAL MODELS AND COMPUTER SIMULATIONS Vol. 3 No. 6 2011
TSVETKOV
generator. The CLHEP version also differs by the way the integer 32bit output of the generator is trans
formed into a doubleprecision number. The Mersenne Twister generator as it was proposed by its authors
passes the DIEHARD tests [2].
Table 1 shows the full list of tested pseudorandom number generators, with the reference given. A sep
arate column indicates whether the generator passes all DIEHARD tests. The name of the generator con
sists of two parts separated by a double colon. The first part is the name of its package. The second part is
the name of the generator within the package. For the MCNP generator, the second part coincides with
the name of the function called to generate random numbers. The Mersenne Twister generator in its orig
inal version is the exception
5. CHOOSING PARAMETERS
The dimension k and the number of decompositions of the edge S principally depend on the RAM vol
ume. The available RAM should be sufficient to store cells of the hypercube. To bypass this, publica
tions suggested calculating hits in only some cells, leaving the hits in the rest of the cells aside. In this work,
we do it in a different way. We divide all cells into several groups so that the cells of each group can be fitted
in the computers memory. For each cell of the group, we find the number of hits by kdimensional points
taken from the tested part of the sequence , , and calculate the value , where r is the number
of the group. The value for the entire hypercube can be calculated by the formula
, (6)
where R is the number of groups, is the number of cells in the rth group, and is the number of hits
of the ith cell of the rth group. Formula (5) differs from formula (6) only by the fact that the sum over all
cells of the hypercube is transformed into two double sums: one is with respect to groups, the other is with
respect to cells of the group. This allows increasing the available memory by R times since cells of only one
group are stored at every instant.
If the number of possible different PRNG outputs cannot be divided entirely by the number of decom
positions S, the mathematical expectation of the number of hits into the cell is not the same for all cells,
and formula (5) yields a systematic error. Since the PRNG output consists of sequence of bits of length b,
it is necessary and sufficient that , for the number of possible outputs of the generator
expressed by to be divided by S.
For fixed values of k and r, we varied the number of points M by the formula
, .
k
S
{ }
i
r 1. . . i M =
2
r

( )
2
2 2
1 1 1
r
R S R
r i
r
r i r
X MX
MX
= = =

= =

r
S
r i
X
2
r
S = 0,1,..., r b =
2
b
10
k
M S m =
max
1,2,..., m m =
Table 1. Tested pseudorandom number generators
Name DIEHARD Tests Source Initial State
CLHEP::Hurd160Engine does not pass [10] Constructor without parameters
CLHEP::Hurd288Engine passes [10] Constructor without parameters
CLHEP::HepJamesRandom does not pass [10] Constructor without parameters
CLHEP::MTwistEngine passes [10] Constructor without parameters
CLHEP::RanecuEngine passes [10] Constructor without parameters
CLHEP::RanluxEngine passes [10] Constructor without parameters
CLHEP::Ranlux64Engine passes [10] Constructor without parameters
CLHEP::RanshiEngine passes [10] Constructor without parameters
CLHEP::TripleRand passes [10] Constructor without parameters
CLHEP::DualRand passes [10] Constructor without parameters
MCNP::rang N/A [9] As in MCNP program
Matlab::twister N/A [11] Calling rand('twister',5489)
Mersenne Twister passes [12] Value as in mt19937ar.c.
MATHEMATICAL MODELS AND COMPUTER SIMULATIONS Vol. 3 No. 6 2011
EMPIRICAL TESTS FOR STATISTICAL PROPERTIES 701
The parameter takes the values such that the maximum number of points does not exceed .
Table 2 shows the full list of values of the parameters of the tests performed in this work.
Each PRNG was tested with the specified test parameters using formula (3) to construct vectors out of
the sequence of its outputs, with the MCNP generator tested using formula (4) as well. In the latter case,
the period of the generator was exceeded manyfold. This is the reason we performed additional tests for
the MCNP generator for another set of parameters given in Table 3, using formula (4). We chose dimen
sion k of the hypercube so that the number of cells does not exceed the length of the generators period,
which is , divided by . The parameter is chosen so that the maximal number of ran
dom values used in the test and equaling does not exceed the generators period.
6. CHECKING THE ALGORITHMS IMPLEMENTATION
We compared the designed program with the TestU01 library, which includes the test for uniform dis
tribution on a hypercube. We checked it for the linear congruential generator operating by formula
, . The values of yielded by both packages coincide up
to the accuracy of at least six digits.
In [13], tests for uniform distribution on the hypercube are also performed. Comparing them, we found
that the calculated variable corresponds completely to the values given in this work.
We compared the outputs of pseudorandom number generators with the outputs of their original ver
sions to check whether their algorithms are implemented correctly.
7. RESULTS OF THE TESTS
Tables 46 gives the results of testing the chosen PRNG. We recall that we held a series of tests with an
increasing number of points M for each dimension k. The tables show the worst results for the distribution
max
m
12
10
46
2 100 152917
max
m
max
10 152917 m
( )
( )
31
1
16807 mod 2 1
n n
x x
+
=
0
1043618065 x =
2

Table 2. Test parameters


Dimension k 1 2 3 4 5 6 7 8
Number of intervals S
Number of cells S
k
Multiplier m 1,,99 1,,23 1,,11 1,,23 1,,93 1,,93 1,,99 1,,23
Dimension k 9 10 11 12 13 14 15
Number of intervals S
Number of cells S
k
Multiplier m 1,,99 1,,93 1,,11 1,,99 1,,99 1,,99 1,,93
26
2
16
2
11
2
8
2
6
2
5
2
4
2
4
2
26
2
32
2
33
2
32
2
30
2
30
2
28
2
32
2
3
2
3
2
3
2
2
2
2
2
2
2
2
2
27
2
30
2
33
2
24
2
26
2
28
2
30
2
Table 3. The second set of parameters of the tests for the MCNP generator
Dimension k 1 2 3 4 5 6 7 8
Number of intervals S
Number of cells S
k
Multiplier m 1,,10 1,,10 1,,21 1,,43 1,,43 1,,99 1,,21 1,,99
Dimension k 9 10 11 12 13 14 15
Number of intervals S 2 2 2 2
Number of cells S
k
Multiplier m 1,,99 1,,43 1,,10 1,,99 1,,99 1,,99 1,,99
22
2
11
2
7
2
5
2
4
2
3
2
3
2
2
2
22
2
22
2
21
2
20
2
20
2
18
2
21
2
16
2
2
2
2
2
2
2
18
2
20
2
22
2
12
2
13
2
14
2
15
2
702
MATHEMATICAL MODELS AND COMPUTER SIMULATIONS Vol. 3 No. 6 2011
TSVETKOV
function of variable for each series. The values of the distribution function of such that the back
ground hypothesis should be rejected for the confidence level 1% ( or ,
where is the distribution function of with degrees of freedom) are in bold.
Although we found poor parts of some sequences of pseudorandom numbers, we should not jump to
a conclusion on the quality of the generators we checked. If the confidence level is , hypothesis is cast
away with the probability when it is true (an error of the first kind). For the number of tests we held in
this work, even the ideal random number generator should yield poor results in some of them. In other
words, each failure of the generator should be studied separately: we need to find whether the poor result
is due to the generators flaw or is random.
We can choose the confidence level arbitrarily. Our previous experience show that if is greater than
its mathematical expectation by more than by , where is the variance of the
distribution with degrees of freedom, we can say that we found regularity in the sequence of pseu
dorandom numbers. In terms of the distribution function, for big values , it is equivalent to
. (7)
The numbers for which condition (7) is met are shown in bold and underlined in the table. In this work,
this condition allowed finding flaws of two generators: CLHEP::RunluxEngine and CLHEP::HepJames
Random.
For CLHEP::RunluxEngine, condition (7) is met for and . Analysis of the original code
showed that the reason is that this generator yields singleprecision numbers (the mantissa accuracy is 24
bits), although the size of the internal state of the generator would allow yielding numbers of higher pre
cision. Additional tests showed that for , and for CLHEP::Runlux
Engine.
The CLHEP::HepJamesRandom generator (based on the Fibonacci generator and arithmetic series)
also fails the test for and . In this case, the reason is that numbers of the type float are used to
initialize the array of the generators state that is composed of numbers of the type double (most likely, this
is done for the sake of compatibility with the original 1987 version of the generator). Ultimately, the low
2

( )
2
1
0.99 k
S
F

>
( )
2
1
0.01 k
S
F

<
( )
2
1
k
S
F

2
1
k
S

0
H

10 DX
( )
2 1
k
DX S =
2

1
k
S
1
k
S
( )
2 13
1
1 10 k
S
F

<
1 k =
26
2 S =
2
0.27 = 1 k =
24
2 S =
24
10 2 M =
1 k =
26
2 S =
Table 4. Results of the tests for dimensions 15
Name of generator
Dimension
1 2 3 4 5
CLHEP::DualRand 0.995323 0.948053 0.340351 0.768940 0.987268
CLHEP::HepJamesRandom 1.000000 0.699740 0.936632 0.966977 0.886762
CLHEP::Hurd160Engine 0.981242 0.971623 0.958399 0.631339 0.863938
CLHEP::Hurd288Engine 0.559912 0.792181 0.509890 0.757253 0.999971
CLHEP::MTwistEngine 0.994270 0.946652 0.974972 0.899679 0.752039
CLHEP::RanecuEngine 0.998975 0.996958 0.346334 0.709779 0.679632
CLHEP::Ranlux64Engine 0.933658 0.874168 0.850137 0.974327 0.737928
CLHEP::RanluxEngine 1.000000 0.642228 0.777547 0.841973 0.988477
CLHEP::RanshiEngine 0.993416 0.707369 0.972229 0.910035 0.679360
CLHEP::TripleRand 0.995091 0.398372 0.577427 0.993931 0.968364
Matlab::twister 0.959231 0.702784 0.810525 0.569543 0.781814
MersenneTwister 0.906981 0.939482 0.924331 0.906341 0.931654
MCNP::rang 0.709312 0.000000 1.000000 0.000000 0.000000
MCNP::rang, form. (4), table 2 0.887875 0.000000 1.000000 0.000000 0.000240
MCNP::rang, form. (4), table 3 0.992192 0.895684 0.405542 0.701091 0.956045
MATHEMATICAL MODELS AND COMPUTER SIMULATIONS Vol. 3 No. 6 2011
EMPIRICAL TESTS FOR STATISTICAL PROPERTIES 703
orders of elements of this array are initialized as zeros. The final output of the generator is expressed as the
sum of several such numbers, and the low orders of the sum are also zero.
When we use formula (3), the linear congruential MCNP generator shows excessively good results
( for ) or excessively poor results ( for ) in
most tests. If we apply the criterion strictly, the MCNP generator should be treated as unsuccessful for
2 10
1
( ) 10 k
S
F

< 2,4,5,6,8,11 k =
2 16
1
1 ( ) 10 k
S
F

< 3,10,15 k =
2

Table 5. Results of the tests for dimensions 610


Name of generator
Dimension
6 7 8 9 10
CLHEP::DualRand 0.998447 0.947438 0.794921 0.865710 0.981127
CLHEP::HepJamesRandom 0.928390 0.948037 0.874440 0.531962 0.831159
CLHEP::Hurd160Engine 0.867428 0.974473 0.694394 0.906157 0.928675
CLHEP::Hurd288Engine 0.976666 0.931154 0.994599 0.953089 0.946499
CLHEP::MTwistEngine 0.944401 0.947856 0.951318 0.878380 0.871078
CLHEP::RanecuEngine 0.900535 0.870693 0.705390 0.773634 0.619596
CLHEP::Ranlux64Engine 0.960292 0.997410 0.917534 0.810551 0.990689
CLHEP::RanluxEngine 0.908988 0.740307 0.493492 0.999962 0.937359
CLHEP::RanshiEngine 0.921317 0.978640 0.977095 0.904776 0.934596
CLHEP::TripleRand 0.962025 0.975680 0.988473 0.876030 0.983850
Matlab::twister 0.982808 0.892043 0.864386 0.758089 0.882524
MersenneTwister 0.652740 0.972370 0.123699 0.954542 0.881406
MCNP::rang 0.000000 0.686396 0.000000 0.966349 1.000000
MCNP::rang, form. (4), table 2 0.000170 0.716351 0.000000 0.447955 0.000460
MCNP::rang, form. (4), table 3 0.970338 0.554682 0.974754 0.997694 0.809440
Table 6. Results of the tests for dimensions 1115
Name of generator
Dimension
11 12 13 14 15
CLHEP::DualRand 0.719233 0.992249 0.860675 0.996457 0.980926
CLHEP::HepJamesRandom 0.712641 0.994541 0.897092 0.913930 0.982666
CLHEP::Hurd160Engine 0.926603 0.621100 0.781813 0.870718 0.869022
CLHEP::Hurd288Engine 0.605796 0.892075 0.993454 0.880340 0.918822
CLHEP::MTwistEngine 0.702732 0.945537 0.995183 0.959703 0.963883
CLHEP::RanecuEngine 0.463223 0.997308 0.994291 0.961549 0.979455
CLHEP::Ranlux64Engine 0.832675 0.833761 0.941638 0.656001 0.649961
CLHEP::RanluxEngine 0.950575 0.970415 0.978212 0.959645 0.974383
CLHEP::RanshiEngine 0.627794 0.875232 0.979792 0.827643 0.961835
CLHEP::TripleRand 0.758260 0.958929 0.833010 0.766343 0.996794
Matlab::twister 0.79999 0.772256 0.924101 0.937104 0.535502
MersenneTwister 0.783843 0.834689 0.976387 0.876684 0.992235
MCNP::rang 0.000000 0.999928 0.852539 0.247564 1.000000
MCNP::rang, form. (4), table 2 0.000000 0.890796 0.569861 0.444289 1.000000
MCNP::rang, form. (4), table 3 0.974945 0.834962 0.516098 0.611708 0.954597
704
MATHEMATICAL MODELS AND COMPUTER SIMULATIONS Vol. 3 No. 6 2011
TSVETKOV
these dimensions. However, excessively good results are also shown by sequences of quasirandom num
bers, which are shown to be used in the Monte Carlo methods in [7], for instance. Although the MCNP
generator may be taken as a quasirandom number generator in some problems, this is yet to be studied.
When we tested this generator using formula (4) and parameters from Table 2, it improved slightly: the
number of results requiring rejection of the background hypothesis became significantly smaller despite
the fact that the period of the generator was exceeded manyfold in this case.
When we tested this generator using formula (4) and parameters from Table 3, the background hypoth
esis had to be rejected only for dimension . Testing for other numbers of decompositions S for the
same dimension shows that this is most likely random rather than a flaw. The chosen track length
should be acknowledged as successful for this generator.
Figure 1 shows the behavior of the Mersenne Twister generator for . For this dimension, the
sequence of length points has , and the background
hypothesis on the uniformity of the sequence should be rejected for confidence level 1%. The figure shows
that the failure of the Mersenne Twister generator in the test for is random. In the other cases that
require formal rejection of the background hypothesis, the behavior of the Mersenne Twister, Mat
lab::twister and CLHEP::MTwistEngine generators does not allow making conclusions on whether there
is a flaw either. In the additional test for the Mersenne Twister generator for , the number of decom
positions and number of points , the value of the distribution function turned out to be
. In this case, the hypothesis on the uniformity of the generator should be formally
rejected as well.
Tables 46 do not ensure that the generator that passed the test successfully yields the true result in the
problem of the same dimension and the same number of points as in the test. The generators failure for
the particular dimension can cause a systematic error in some problems. In this work, there is no sense in
elaborating on the behavior of all generators chosen to be tested; thus, we restrict ourselves to representing
the results of their testing.
1 k =
152917 K =
15 k =
10
42949672960 4.3 10 M =
2
1
( ) 0.992 k
S
F

=
15 k =
6 k =
16 S =
6
10 16 M =
2
1
( ) 0.995 k
S
F

=
1.0
0.8
0.6
0.4
0.2
0 10 2 4 6 8
F
(
x
2
)
M
10
11
The value of the distribution function
2
depending on the number of points M for the dimension k = 15 for the Mersenne
Twister generator.
MATHEMATICAL MODELS AND COMPUTER SIMULATIONS Vol. 3 No. 6 2011
EMPIRICAL TESTS FOR STATISTICAL PROPERTIES 705
8. CONCLUSIONS
We found some parts of the sequences of pseudorandom numbers of the tested PRNGs that can lead
to a systematic error of computations.
Most of the linear congruential generators are known to fail the DIEHARD tests. However, such gen
erators have indisputable advantages, viz., good theoretical exploration and speed of operation. In addi
tion, the generator can be transferred to any subsequent state, without going through all intermediate
states. These advantages justify using linear congruential generators in many programs. Although the
structure of points obtained from the outputs of these generators is well studied and is far from random,
the MCNP still uses a linear congruential generator. The tests we held in this work showed that this gen
erator has an acceptable quality if we use pseudorandom numbers in the same order as in MCNP.
One should implement the CLHEP::HepJamesRandom and CLHEP::RanluxEngine generators care
fully: their outputs yield singleprecision numbers instead of the stated double precision.
The general practice of choosing generators is that most works tend to use generators with a good rep
utation. These currently, unconditionally include the Mersenne Twister, which was verified in this work.
Given the numerous practical problems solved by the MCNP program, we can say that within the MCNP
project, its standard generator also has a good reputation.
REFERENCES
1. D. Knuth, Art of Computer Programming, Volume 2: Seminumerical Algorithms (3rd Edition) (AddisonWesley
Professional, 1997).
2. Makoto Matsumoto and Takuji Nishimura, Mersenne Twister: a 623Dimensionally Equidistributed Uniform
PseudoRandom Number Generator, in ACM Transactions on Modeling and Computer Simulation (TOMACS),
January 1998, 8 (1), 330.
3. The Marsaglia Random Number CDROM including the Diehard Battery of Tests of Randomness.
http://stat.fsu.edu/rub/diehard/ (Cited April 28, 2010).
4. P. LEcuyer and R. Simard, TestU01: A C Library for Empirical Testing of Random Number Generators in
ACM Transactions on Mathematical Software (TOMS), 33 (4), August 2007.
5. A. Rukhin, J. Soto, and J. Nechvatal, A Statistical Test Suite for Random and Pseudorandom Number Gener
ators for Cryptographic Applications, National Institute of Standards and Technology, NIST Special Publica
tion 80022, Revision 1, Revised: August 2008.
6. G. Marsaglia, Random Numbers Fall Mainly in the Planes, in Proc. Nat. Acad. Sci. USA, 61 (23) (1968).
7. I. M. Sobol, Monte Carlo Numerical Methods (Nauka, Glavnaya redaktsiya fizikomatematicheskoi literatury,
Moscow, 1973) [in Russian].
8. S. M. Ermakov, Statistical Simulation. Manual. Part 1. Simulation of Distributions (izd. NIIKh SpbGU, St.
Petersburg, 2006) [in Russian].
9. MCNP A General Monte Carlo NParticle Transport Code, Version 5. Volume I: Overview and Theory, X5
Monte Carlo Team (Los Alamos: Los Alamos National Laboratory, April 2003).
10. Joe Voudreau, Walter Vrown, Gabriele Sosmo et. al., SLHEP A Class Library for High Energy Physics.
http://cern.ch/CLHEP (Cited April 28, 2010).
11. MathWorks MATLAB and Simulink for Technical Computing. http://www.mathworks.som/ (Cited April 28,
2010).
12. Mersenne Twister Home Rage. http://www.math.sci.hiroshimau.as.jr/~mmat/MT/emt.html (Cited April 28,
2010).
13. S. M. Ermakov and G. A. Mikhailov, Statistical Simulation, 1st ed. (Nauka, Glavnaya redaktsiya fizikomatem
aticheskoi literatury, Moscow, 1982) [in Russian].

Das könnte Ihnen auch gefallen