coll.test {randtoolbox} | R Documentation |
the Collision test
Description
The Collision test for testing random number generators.
Usage
coll.test(rand, lenSample = 2^14, segments = 2^10, tdim = 2,
nbSample = 1000, echo = TRUE, ...)
Arguments
rand |
a function generating random numbers. its first argument must be
the 'number of observation' argument as in |
lenSample |
numeric for the length of generated samples. |
segments |
numeric for the number of segments to which the interval |
tdim |
numeric for the length of the disjoint t-tuples. |
nbSample |
numeric for the overall sample number. |
echo |
logical to plot detailed results, default |
... |
further arguments to pass to function rand |
Details
We consider outputs of multiple calls to a random number generator rand
.
Let us denote by the length of samples (i.e.
lenSample
argument),
the number of cells (i.e.
nbCell
argument) and
the number of samples (i.e.
nbSample
argument).
A collision is defined as
when a random number falls in a cell where there are
already random numbers. Let us note the number of collisions
The distribution of collision number is given by
where denotes the Stirling number of the second kind
and
.
But we cannot use this formula for large since the Stirling number
need
time to be computed. We use
a Gaussian approximation if
and
,
a Poisson approximation if
and the exact formula
otherwise.
Finally we compute samples of random numbers, on which we calculate
the number of collisions. Then we are able to compute a chi-squared statistic.
Value
a list with the following components :
statistic
the value of the chi-squared statistic.
p.value
the p-value of the test.
observed
the observed counts.
expected
the expected counts under the null hypothesis.
residuals
the Pearson residuals, (observed - expected) / sqrt(expected).
Author(s)
Christophe Dutang.
References
Planchet F., Jacquemin J. (2003), L'utilisation de methodes de simulation en assurance. Bulletin Francais d'Actuariat, vol. 6, 11, 3-69. (available online)
L'Ecuyer P. (2001), Software for uniform random number generation distinguishing the good and the bad. Proceedings of the 2001 Winter Simulation Conference. doi:10.1109/WSC.2001.977250
L'Ecuyer P. (2007), Test U01: a C library for empirical testing of random number generators. ACM Trans. on Mathematical Software 33(4), 22. doi:10.1145/1268776.1268777
See Also
other tests of this package coll.test.sparse
, freq.test
, serial.test
, poker.test
,
order.test
and gap.test
ks.test
for the Kolmogorov Smirnov test and acf
for
the autocorrelation function.
Examples
# (1) poisson approximation
#
coll.test(runif, 2^7, 2^10, 1, 100)
# (2) exact distribution
#
coll.test(SFMT, 2^7, 2^10, 1, 100)