Description Usage Arguments Details Value Author(s) References See Also Examples

The Collision test for testing random number generators.

1 2 |

`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 |

We consider outputs of multiple calls to a random number generator `rand`

.
Let us denote by *n* the length of samples (i.e. `lenSample`

argument),
*k* the number of cells (i.e. `nbCell`

argument) and
*m* 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 *C* the number of collisions

The distribution of collision number *C* is given by

*
P(C = c) = ∏_{i=0}^{n-c-1} (k-i)/k *1/(k^c) 2S_n^{n-c},
*

where *2S_n^{n-c}* denotes the Stirling number of the second kind
and *c=0,..., n-1*.

But we cannot use this formula for large *n* since the Stirling number
need *O(n log(n))* time to be computed. We use
a Gaussian approximation if
* n/k>\frac{1}{32} * and *n >= 2^8*,
a Poisson approximation if *n/k < 1/32* and the exact formula
otherwise.

Finally we compute *m* samples of random numbers, on which we calculate
the number of collisions. Then we are able to compute a chi-squared statistic.

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

Christophe Dutang.

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.

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.

1 2 3 4 5 6 7 |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.