pokertest: the Poker test

poker.testR Documentation

the Poker test

Description

The Poker test for testing random number generators.

Usage

poker.test(u , nbcard = 5, echo = TRUE)

Arguments

u

sample of random numbers in ]0,1[.

echo

logical to plot detailed results, default TRUE

nbcard

a numeric for the number of cards, we assume that the length of u is a multiple of nbcard.

Details

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

Let us note k the card number (i.e. nbcard). The poker test computes a serie of 'hands' in \{0, \dots, k-1\} from the sample h_i = \lfloor u_i d\rfloor (u must have a length dividable by k). Let n_j be the number of 'hands' with (exactly) j different cards. The probability is

p_j = \frac{k!}{k^k (k-j)!* S_k^j} * (\frac{j}{k})^(k-j),

where S_k^j denotes the Stirling numbers of the second kind. Finally the chi-squared statistic is

S = \sum_{j=0}^{k-1} \frac{n_j - np_j/k)^2}{np_j/k}.

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. \Sexpr[results=rd]{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. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1145/1268776.1268777")}

See Also

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

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

Examples

# (1) hands of 5 'cards'
#
poker.test(runif(50000))

# (2) hands of 4 'cards'
#
poker.test(runif(40000), 4)

# (3) hands of 42 'cards'
#
poker.test(runif(420000), 42)


randtoolbox documentation built on Oct. 18, 2024, 5:13 p.m.