Date: Dec 4, 2012 8:56 AM
Author: Luis A. Afonso
Subject: Checking a RNG by H (Fisher)
Checking a RNG by H (Fisher)

Fisher propose to use to check the p-values issued from NHST multiple tests through the r.v. H because the quantity H (Fisher) = -2*Sum (1, n) LOG (U) follows a 2*n degrees of freedom Chi-square distribution.

For each attempt 400´000 samples size 40 of RND´s were obtained and H calculated.

The interval [57.1532, 106.6286] should contain exactly 95% of H´s (Chi-square 80 d.f.).

Results:

__attempt 1, 2, 3, 4 : 0.94989, 0.95014, 0.95012, 0.94979.

__mean, standard error : 0.9500 , 0.0001

Luis A. Afonso

REM "HH7"

CLS

DEFDBL A-Z

RANDOMIZE TIMER

PRINT "____________HH7______________"

PRINT " AIM : Check Generator by samples size N ";

PRINT " after --> H(Fisher)=SUM(1,N).-2*LOG(RND) = CHI2";

PRINT " must [QUI(.025), QUI(.975)], 2N d.f."

PRINT " contains inside 95% "

REM

PRINT

INPUT " size=40 "; n

INPUT " repeat= "; ali

REM

INPUT " left QUI(.05) 57.1532"; left

INPUT " right (.95) 106.6286"; right

DIM x(n)

RANDOMIZE TIMER

FOR t = 1 TO ali

REM

LOCATE 15, 50: PRINT USING "########"; ali - t

H = 0

FOR j = 1 TO n

3 x(j) = RND

IF x(j) > 1 - 1E-15 THEN GOTO 3

LOCATE 15, 2

H = H - 2 * LOG(1 - x(j))

NEXT j

IF H > left AND H < right THEN inn = inn + 1

NEXT t

PRINT inn / ali

END