R: the Frequency test

freq.test {randtoolbox} | R Documentation

## the Frequency test

### Description

The Frequency test for testing random number generators.

### Usage

    freq.test(u, seq = 0:15, echo = TRUE)

### Arguments

`u` | sample of random numbers in ]0,1[.
`echo` | logical to plot detailed results, default `TRUE`
`seq` | a vector of contiguous integers, default `0:15`.

### Details

We consider a vector `u`, realisation of i.i.d. uniform random variables U1... Un.

The frequency test works on a serie `seq` of ordered contiguous integers (s_1, ...,s_d), where s_j in Z. From the sample `u`, we compute observed integers as

d_i = floor( u_i * ( s_d + 1 ) + s_1 ),

(i.e. d_i are uniformely distributed in {s_1, ...,s_d}). The expected number of integers equals to j is m=n/(s_d - s_1+1). Finally, the chi-squared statistic is

S = ∑_{j=1}^d (card(d_i=s_j) - m)^2/m .

### 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. (available online)

L'Ecuyer P. (2007), Test U01: a C library for empirical testing of random number generators. ACM Trans. on Mathematical Software 33(4), 22.

### See Also

other tests of this package `gap.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)
    #
    freq.test(runif(1000))
    print( freq.test( runif(10000), echo=FALSE) )

    # (2)
    #
    freq.test(runif(1000), 1:4)

    freq.test(runif(1000), 10:40)

[Package randtoolbox version 2.0.0 Index]