Divide the input sequence into n groups of t elements each, that is, (U[jt], U[jt+1], ,,, U[jt+t-1] for 0 <= j < n. The elements in each group can have t! possible relative orderings; the number of times each ordering appears is counted, and a chi-square test is applied with k = t! and with probability 1/t! for each ordering. In the test t is chosen to be 10. The function returns a uniform no. in [0,1]. The test is failed if the value less than 0.001 or larger than 0.999

The function returns a uniform random no. in [0,1]. The test is failed if the value less than 0.001 or larger than 0.999