Learn R Programming

randtoolbox (version 2.0.5)

order.test: the Order test

Description

The Order test for testing random number generators.

Usage

order.test(u, d = 3, echo = TRUE)

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).

Arguments

u

sample of random numbers in ]0,1[.

echo

logical to plot detailed results, default TRUE

d

a numeric for the dimension, see details. When necessary we assume that d is a multiple of the length of u.

Author

Christophe Dutang.

Details

We consider a vector u, realisation of i.i.d. uniform random variables \(U_1, \dots, U_n\).

The Order test works on a sequence of d-uplets (\(x,y,z\) when d=3) of uniform i.i.d. random variables. The triplet is build from the vector \(u\). The number of permutation among the components of a triplet is \(3!=6\), i.e. \(x<y<z\), \(x<z<y\), \(y<x<z\), \(y<z<x\), \(z<x<y\) and \(z<y<x\). The Marsaglia test computes the empirical of the different permutations as well as the theoretical one \(n/6\) where \(n\) is the number of triplets. Finally the chi-squared statistic is $$ S = \sum_{j=0}^{6} \frac{n_j - n/6)^2}{n/6}. $$

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. tools:::Rd_expr_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. tools:::Rd_expr_doi("10.1145/1268776.1268777")

See Also

other tests of this package freq.test, serial.test, poker.test, gap.test and coll.test

ks.test for the Kolmogorov Smirnov test and acf for the autocorrelation function.

Examples

Run this code
# (1) mersenne twister vs torus
#
order.test(runif(6000))
order.test(torus(6000))

# (2) 
#
order.test(runif(4000), 4)
order.test(torus(4000), 4)

# (3) 
#
order.test(runif(5000), 5)
order.test(torus(5000), 5)


Run the code above in your browser using DataLab