gap.test {randtoolbox} | R Documentation |
the Gap test
Description
The Gap test for testing random number generators.
Usage
gap.test(u, lower = 0, upper = 1/2, echo = TRUE)
Arguments
u |
sample of random numbers in ]0,1[. |
lower |
numeric for the lower bound, default |
upper |
numeric for the upper bound, default |
echo |
logical to plot detailed results, default |
Details
We consider a vector u
, realisation of i.i.d. uniform random
variables .
The gap test works on the 'gap' variables defined as
Let the probability that
equals to one.
Then we compute the length of zero gaps and denote by
the number
of zero gaps of length
. The chi-squared statistic is given by
where stands for the probability the length of zero gaps equals
to
(
) and
the max number of lengths (at least
).
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 freq.test
, serial.test
, poker.test
,
order.test
and coll.test
ks.test
for the Kolmogorov Smirnov test and acf
for
the autocorrelation function.
Examples
# (1)
#
gap.test(runif(1000))
print( gap.test( runif(1000000), echo=FALSE ) )
# (2)
#
gap.test(runif(1000), 1/3, 2/3)