乱数ライブラリー

Uniformity test in 1 dimensional

For pseudo-random number $x_0,x_1,\ldots ,x_{N-1}$ generated is a uniform pseudo-random sequence, it can be ascertained by testing whether its frequency distribution has the nature of the equal probability.

Chi square goodness-of-fit test

By dividing the range of values that pseudo-random number sequence takes into $k$ equally spaced intervals, the numbers of random numbers in each interval $\left\{f_1,f_2,\ldots ,f_k\right\}$ are obtained. When the pseudo-random number sequence is in the uniform, $\chi^2$ statistic approaches to the $\chi^2$ distribution with $(k-1)$ degrees of freedom asymptotically.

$\chi ^2=\sum _{i=1}^k\frac{\left(f_i-\frac{N}{k}\right){}^2}{\frac{N}{k}}$
(1)


The null hypothesis $H_0$ is as follows,

  $H_0$: pseudo-random number sequence is uniform.

Comparing the calculated $\chi^2$statistics with $\chi _{k-1}^2(\alpha)$ which is the $\chi^2$ distribution of $(k-1)$ freedom at $\alpha$ point, determined as follows,

  • $\chi ^2\leq \chi _{k-1}^2(\alpha)$: Null hypothesis $H_0$ is adopted, pseudo-random number sequence is uniform.
  • $\chi ^2>\chi _{k-1}^2(\alpha)$: Null hypothesis $H_0$ is rejected, pseudo-random number sequence is not uniform.



Reference:
  • JIS Z 9031:2012, Procedure for random number generation and randomization



Back to this TOP