I recently tested the pseudo-random number generator (PRNG) used in PopTools using George Marsaglia's DIEHARD battery of tests. The PRNG comes from the TPMath library and -- as I read the file below -- passed all the tests. What follows is the unedited output produced by the DOS version of DIEHARD after analysing an 11 Mb file of 32-bit integers called FRED.BIN. This files was produced by direct calls to the DLL.
NOTE: Most of the tests in DIEHARD return a p-value, which
should be uniform on [0,1) if the input file contains truly
independent random bits. Those p-values are obtained by
p=F(X), where F is the assumed distribution of the sample
random variable X---often normal. But that assumed F is just
an asymptotic approximation, for which the fit will be worst
in the tails. Thus you should not be surprised with
occasional p-values near 0 or 1, such as .0012 or .9983.
When a bit stream really FAILS BIG, you will get p's of 0 or
1 to six or more places. By all means, do not, as a
Statistician might, think that a p < .025 or p> .975 means
that the RNG has "failed the test at the .05 level". Such
p's happen among the hundreds that DIEHARD produces, even
with good RNG's. So keep in mind that " p happens".
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: This is the BIRTHDAY SPACINGS TEST ::
:: Choose m birthdays in a year of n days. List the spacings ::
:: between the birthdays. If j is the number of values that ::
:: occur more than once in that list, then j is asymptotically ::
:: Poisson distributed with mean m^3/(4n). Experience shows n ::
:: must be quite large, say n>=2^18, for comparing the results ::
:: to the Poisson distribution with that mean. This test uses ::
:: n=2^24 and m=2^9, so that the underlying distribution for j ::
:: is taken to be Poisson with lambda=2^27/(2^26)=2. A sample ::
:: of 500 j's is taken, and a chi-square goodness of fit test ::
:: provides a p value. The first test uses bits 1-24 (counting ::
:: from the left) from integers in the specified file. ::
:: Then the file is closed and reopened. Next, bits 2-25 are ::
:: used to provide birthdays, then 3-26 and so on to bits 9-32. ::
:: Each set of bits provides a p-value, and the nine p-values ::
:: provide a sample for a KSTEST. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
BIRTHDAY SPACINGS TEST, M= 512 N=2**24 LAMBDA= 2.0000
Results for fred.bin
For a sample of size 500: mean
fred.bin using bits 1 to 24 1.978
duplicate number number
spacings observed expected
0 65. 67.668
1 141. 135.335
2 129. 135.335
3 97. 90.224
4 47. 45.112
5 16. 18.045
6 to INF 5. 8.282
Chisquare with 6 d.o.f. = 2.76 p-value= .161571
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
fred.bin using bits 2 to 25 2.118
duplicate number number
spacings observed expected
0 51. 67.668
1 145. 135.335
2 126. 135.335
3 97. 90.224
4 48. 45.112
5 22. 18.045
6 to INF 11. 8.282
Chisquare with 6 d.o.f. = 7.89 p-value= .753925
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
fred.bin using bits 3 to 26 2.082
duplicate number number
spacings observed expected
0 51. 67.668
1 146. 135.335
2 129. 135.335
3 102. 90.224
4 43. 45.112
5 18. 18.045
6 to INF 11. 8.282
Chisquare with 6 d.o.f. = 7.77 p-value= .744613
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
fred.bin using bits 4 to 27 1.996
duplicate number number
spacings observed expected
0 69. 67.668
1 135. 135.335
2 127. 135.335
3 99. 90.224
4 47. 45.112
5 14. 18.045
6 to INF 9. 8.282
Chisquare with 6 d.o.f. = 2.44 p-value= .125109
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
fred.bin using bits 5 to 28 2.020
duplicate number number
spacings observed expected
0 62. 67.668
1 144. 135.335
2 130. 135.335
3 89. 90.224
4 47. 45.112
5 20. 18.045
6 to INF 8. 8.282
Chisquare with 6 d.o.f. = 1.56 p-value= .044373
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
fred.bin using bits 6 to 29 2.004
duplicate number number
spacings observed expected
0 74. 67.668
1 131. 135.335
2 136. 135.335
3 81. 90.224
4 47. 45.112
5 20. 18.045
6 to INF 11. 8.282
Chisquare with 6 d.o.f. = 2.86 p-value= .173883
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
fred.bin using bits 7 to 30 2.076
duplicate number number
spacings observed expected
0 56. 67.668
1 131. 135.335
2 138. 135.335
3 108. 90.224
4 41. 45.112
5 18. 18.045
6 to INF 8. 8.282
Chisquare with 6 d.o.f. = 6.09 p-value= .586823
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
fred.bin using bits 8 to 31 2.014
duplicate number number
spacings observed expected
0 68. 67.668
1 139. 135.335
2 131. 135.335
3 95. 90.224
4 32. 45.112
5 23. 18.045
6 to INF 12. 8.282
Chisquare with 6 d.o.f. = 7.33 p-value= .708910
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
fred.bin using bits 9 to 32 2.052
duplicate number number
spacings observed expected
0 63. 67.668
1 133. 135.335
2 133. 135.335
3 94. 90.224
4 47. 45.112
5 23. 18.045
6 to INF 7. 8.282
Chisquare with 6 d.o.f. = 2.20 p-value= .099467
:::::::::::::::::::::::::::::::::::::::::
The 9 p-values were
.161571 .753925 .744613 .125109 .044373
.173883 .586823 .708910 .099467
A KSTEST for the 9 p-values yields .812364
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: THE OVERLAPPING 5-PERMUTATION TEST ::
:: This is the OPERM5 test. It looks at a sequence of one mill- ::
:: ion 32-bit random integers. Each set of five consecutive ::
:: integers can be in one of 120 states, for the 5! possible or- ::
:: derings of five numbers. Thus the 5th, 6th, 7th,...numbers ::
:: each provide a state. As many thousands of state transitions ::
:: are observed, cumulative counts are made of the number of ::
:: occurences of each state. Then the quadratic form in the ::
:: weak inverse of the 120x120 covariance matrix yields a test ::
:: equivalent to the likelihood ratio test that the 120 cell ::
:: counts came from the specified (asymptotically) normal dis- ::
:: tribution with the specified 120x120 covariance matrix (with ::
:: rank 99). This version uses 1,000,000 integers, twice. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
OPERM5 test for file fred.bin
For a sample of 1,000,000 consecutive 5-tuples,
chisquare for 99 degrees of freedom= 64.787; p-value= .003123
OPERM5 test for file fred.bin
For a sample of 1,000,000 consecutive 5-tuples,
chisquare for 99 degrees of freedom= 86.737; p-value= .194132
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: This is the BINARY RANK TEST for 31x31 matrices. The leftmost ::
:: 31 bits of 31 random integers from the test sequence are used ::
:: to form a 31x31 binary matrix over the field {0,1}. The rank ::
:: is determined. That rank can be from 0 to 31, but ranks< 28 ::
:: are rare, and their counts are pooled with those for rank 28. ::
:: Ranks are found for 40,000 such random matrices and a chisqua-::
:: re test is performed on counts for ranks 31,30,29 and <=28. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Binary rank test for fred.bin
Rank test for 31x31 binary matrices:
rows from leftmost 31 bits of each 32-bit integer
rank observed expected (o-e)^2/e sum
28 211 211.4 .000826 .001
29 5093 5134.0 .327588 .328
30 23117 23103.0 .008427 .337
31 11579 11551.5 .065351 .402
chisquare= .402 for 3 d. of f.; p-value= .323191
--------------------------------------------------------------
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: This is the BINARY RANK TEST for 32x32 matrices. A random 32x ::
:: 32 binary matrix is formed, each row a 32-bit random integer. ::
:: The rank is determined. That rank can be from 0 to 32, ranks ::
:: less than 29 are rare, and their counts are pooled with those ::
:: for rank 29. Ranks are found for 40,000 such random matrices ::
:: and a chisquare test is performed on counts for ranks 32,31, ::
:: 30 and <=29. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Binary rank test for fred.bin
Rank test for 32x32 binary matrices:
rows from leftmost 32 bits of each 32-bit integer
rank observed expected (o-e)^2/e sum
29 229 211.4 1.462156 1.462
30 5067 5134.0 .874633 2.337
31 23111 23103.0 .002738 2.340
32 11593 11551.5 .148918 2.488
chisquare= 2.488 for 3 d. of f.; p-value= .579960
--------------------------------------------------------------
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: This is the BINARY RANK TEST for 6x8 matrices. From each of ::
:: six random 32-bit integers from the generator under test, a ::
:: specified byte is chosen, and the resulting six bytes form a ::
:: 6x8 binary matrix whose rank is determined. That rank can be ::
:: from 0 to 6, but ranks 0,1,2,3 are rare; their counts are ::
:: pooled with those for rank 4. Ranks are found for 100,000 ::
:: random matrices, and a chi-square test is performed on ::
:: counts for ranks 6,5 and <=4. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Binary Rank Test for fred.bin
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 1 to 8
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 941 944.3 .012 .012
r =5 21873 21743.9 .767 .778
r =6 77186 77311.8 .205 .983
p=1-exp(-SUM/2)= .38822
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 2 to 9
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 996 944.3 2.830 2.830
r =5 21727 21743.9 .013 2.844
r =6 77277 77311.8 .016 2.859
p=1-exp(-SUM/2)= .76060
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 3 to 10
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 936 944.3 .073 .073
r =5 21913 21743.9 1.315 1.388
r =6 77151 77311.8 .334 1.723
p=1-exp(-SUM/2)= .57737
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 4 to 11
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 940 944.3 .020 .020
r =5 21964 21743.9 2.228 2.248
r =6 77096 77311.8 .602 2.850
p=1-exp(-SUM/2)= .75948
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 5 to 12
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 956 944.3 .145 .145
r =5 21745 21743.9 .000 .145
r =6 77299 77311.8 .002 .147
p=1-exp(-SUM/2)= .07091
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 6 to 13
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 951 944.3 .048 .048
r =5 21685 21743.9 .160 .207
r =6 77364 77311.8 .035 .242
p=1-exp(-SUM/2)= .11410
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 7 to 14
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 914 944.3 .972 .972
r =5 21681 21743.9 .182 1.154
r =6 77405 77311.8 .112 1.267
p=1-exp(-SUM/2)= .46917
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 8 to 15
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 947 944.3 .008 .008
r =5 21736 21743.9 .003 .011
r =6 77317 77311.8 .000 .011
p=1-exp(-SUM/2)= .00545
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 9 to 16
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 931 944.3 .187 .187
r =5 21873 21743.9 .767 .954
r =6 77196 77311.8 .173 1.127
p=1-exp(-SUM/2)= .43088
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 10 to 17
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 983 944.3 1.586 1.586
r =5 21790 21743.9 .098 1.684
r =6 77227 77311.8 .093 1.777
p=1-exp(-SUM/2)= .58866
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 11 to 18
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 982 944.3 1.505 1.505
r =5 21905 21743.9 1.194 2.699
r =6 77113 77311.8 .511 3.210
p=1-exp(-SUM/2)= .79909
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 12 to 19
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 967 944.3 .546 .546
r =5 21973 21743.9 2.414 2.959
r =6 77060 77311.8 .820 3.780
p=1-exp(-SUM/2)= .84890
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 13 to 20
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 944 944.3 .000 .000
r =5 21919 21743.9 1.410 1.410
r =6 77137 77311.8 .395 1.805
p=1-exp(-SUM/2)= .59452
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 14 to 21
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 959 944.3 .229 .229
r =5 21816 21743.9 .239 .468
r =6 77225 77311.8 .097 .565
p=1-exp(-SUM/2)= .24623
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 15 to 22
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 961 944.3 .295 .295
r =5 21510 21743.9 2.516 2.811
r =6 77529 77311.8 .610 3.422
p=1-exp(-SUM/2)= .81927
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 16 to 23
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 930 944.3 .217 .217
r =5 21741 21743.9 .000 .217
r =6 77329 77311.8 .004 .221
p=1-exp(-SUM/2)= .10452
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 17 to 24
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 942 944.3 .006 .006
r =5 21623 21743.9 .672 .678
r =6 77435 77311.8 .196 .874
p=1-exp(-SUM/2)= .35408
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 18 to 25
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 962 944.3 .332 .332
r =5 21475 21743.9 3.325 3.657
r =6 77563 77311.8 .816 4.473
p=1-exp(-SUM/2)= .89318
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 19 to 26
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 970 944.3 .699 .699
r =5 21732 21743.9 .007 .706
r =6 77298 77311.8 .002 .708
p=1-exp(-SUM/2)= .29825
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 20 to 27
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 966 944.3 .499 .499
r =5 21673 21743.9 .231 .730
r =6 77361 77311.8 .031 .761
p=1-exp(-SUM/2)= .31651
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 21 to 28
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 940 944.3 .020 .020
r =5 21748 21743.9 .001 .020
r =6 77312 77311.8 .000 .020
p=1-exp(-SUM/2)= .01013
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 22 to 29
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 922 944.3 .527 .527
r =5 21680 21743.9 .188 .714
r =6 77398 77311.8 .096 .811
p=1-exp(-SUM/2)= .33321
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 23 to 30
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 933 944.3 .135 .135
r =5 21707 21743.9 .063 .198
r =6 77360 77311.8 .030 .228
p=1-exp(-SUM/2)= .10771
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 24 to 31
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 952 944.3 .063 .063
r =5 21638 21743.9 .516 .579
r =6 77410 77311.8 .125 .703
p=1-exp(-SUM/2)= .29646
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG fred.bin
b-rank test for bits 25 to 32
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 895 944.3 2.574 2.574
r =5 21690 21743.9 .134 2.708
r =6 77415 77311.8 .138 2.845
p=1-exp(-SUM/2)= .75893
TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices
These should be 25 uniform [0,1] random variables:
.388217 .760597 .577368 .759480 .070915
.114103 .469169 .005451 .430878 .588663
.799093 .848898 .594523 .246228 .819274
.104525 .354076 .893184 .298250 .316513
.010131 .333213 .107706 .296459 .758930
brank test summary for fred.bin
The KS test for those 25 supposed UNI's yields
KS p-value= .624289
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: THE BITSTREAM TEST ::
:: The file under test is viewed as a stream of bits. Call them ::
:: b1,b2,... . Consider an alphabet with two "letters", 0 and 1 ::
:: and think of the stream of bits as a succession of 20-letter ::
:: "words", overlapping. Thus the first word is b1b2...b20, the ::
:: second is b2b3...b21, and so on. The bitstream test counts ::
:: the number of missing 20-letter (20-bit) words in a string of ::
:: 2^21 overlapping 20-letter words. There are 2^20 possible 20 ::
:: letter words. For a truly random string of 2^21+19 bits, the ::
:: number of missing words j should be (very close to) normally ::
:: distributed with mean 141,909 and sigma 428. Thus ::
:: (j-141909)/428 should be a standard normal variate (z score) ::
:: that leads to a uniform [0,1) p value. The test is repeated ::
:: twenty times. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
THE OVERLAPPING 20-tuples BITSTREAM TEST, 20 BITS PER WORD, N words
This test uses N=2^21 and samples the bitstream 20 times.
No. missing words should average 141909. with sigma=428.
---------------------------------------------------------
tst no 1: 142859 missing words, 2.22 sigmas from mean, p-value= .98675
tst no 2: 142073 missing words, .38 sigmas from mean, p-value= .64892
tst no 3: 142059 missing words, .35 sigmas from mean, p-value= .63672
tst no 4: 141817 missing words, -.22 sigmas from mean, p-value= .41460
tst no 5: 142456 missing words, 1.28 sigmas from mean, p-value= .89925
tst no 6: 142703 missing words, 1.85 sigmas from mean, p-value= .96816
tst no 7: 142185 missing words, .64 sigmas from mean, p-value= .74024
tst no 8: 141771 missing words, -.32 sigmas from mean, p-value= .37327
tst no 9: 141943 missing words, .08 sigmas from mean, p-value= .53135
tst no 10: 142376 missing words, 1.09 sigmas from mean, p-value= .86222
tst no 11: 141926 missing words, .04 sigmas from mean, p-value= .51554
tst no 12: 142018 missing words, .25 sigmas from mean, p-value= .60022
tst no 13: 141872 missing words, -.09 sigmas from mean, p-value= .46525
tst no 14: 142142 missing words, .54 sigmas from mean, p-value= .70665
tst no 15: 141918 missing words, .02 sigmas from mean, p-value= .50808
tst no 16: 141119 missing words, -1.85 sigmas from mean, p-value= .03241
tst no 17: 141565 missing words, -.80 sigmas from mean, p-value= .21055
tst no 18: 141715 missing words, -.45 sigmas from mean, p-value= .32490
tst no 19: 142713 missing words, 1.88 sigmas from mean, p-value= .96979
tst no 20: 142936 missing words, 2.40 sigmas from mean, p-value= .99177
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: The tests OPSO, OQSO and DNA ::
:: OPSO means Overlapping-Pairs-Sparse-Occupancy ::
:: The OPSO test considers 2-letter words from an alphabet of ::
:: 1024 letters. Each letter is determined by a specified ten ::
:: bits from a 32-bit integer in the sequence to be tested. OPSO ::
:: generates 2^21 (overlapping) 2-letter words (from 2^21+1 ::
:: "keystrokes") and counts the number of missing words---that ::
:: is 2-letter words which do not appear in the entire sequence. ::
:: That count should be very close to normally distributed with ::
:: mean 141,909, sigma 290. Thus (missingwrds-141909)/290 should ::
:: be a standard normal variable. The OPSO test takes 32 bits at ::
:: a time from the test file and uses a designated set of ten ::
:: consecutive bits. It then restarts the file for the next de- ::
:: signated 10 bits, and so on. ::
:: ::
:: OQSO means Overlapping-Quadruples-Sparse-Occupancy ::
:: The test OQSO is similar, except that it considers 4-letter ::
:: words from an alphabet of 32 letters, each letter determined ::
:: by a designated string of 5 consecutive bits from the test ::
:: file, elements of which are assumed 32-bit random integers. ::
:: The mean number of missing words in a sequence of 2^21 four- ::
:: letter words, (2^21+3 "keystrokes"), is again 141909, with ::
:: sigma = 295. The mean is based on theory; sigma comes from ::
:: extensive simulation. ::
:: ::
:: The DNA test considers an alphabet of 4 letters:: C,G,A,T,::
:: determined by two designated bits in the sequence of random ::
:: integers being tested. It considers 10-letter words, so that ::
:: as in OPSO and OQSO, there are 2^20 possible words, and the ::
:: mean number of missing words from a string of 2^21 (over- ::
:: lapping) 10-letter words (2^21+9 "keystrokes") is 141909. ::
:: The standard deviation sigma=339 was determined as for OQSO ::
:: by simulation. (Sigma for OPSO, 290, is the true value (to ::
:: three places), not determined by simulation. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
OPSO test for generator fred.bin
Output: No. missing words (mw), equiv normal variate (z), p-value (p)
mw z p
OPSO for fred.bin using bits 23 to 32 142027 .406 .6575
OPSO for fred.bin using bits 22 to 31 141238 -2.315 .0103
OPSO for fred.bin using bits 21 to 30 141363 -1.884 .0298
OPSO for fred.bin using bits 20 to 29 141797 -.387 .3493
OPSO for fred.bin using bits 19 to 28 141750 -.549 .2914
OPSO for fred.bin using bits 18 to 27 141500 -1.411 .0791
OPSO for fred.bin using bits 17 to 26 141819 -.311 .3777
OPSO for fred.bin using bits 16 to 25 142063 .530 .7019
OPSO for fred.bin using bits 15 to 24 141980 .244 .5963
OPSO for fred.bin using bits 14 to 23 141601 -1.063 .1438
OPSO for fred.bin using bits 13 to 22 141841 -.236 .4069
OPSO for fred.bin using bits 12 to 21 141882 -.094 .4625
OPSO for fred.bin using bits 11 to 20 141709 -.691 .2448
OPSO for fred.bin using bits 10 to 19 141941 .109 .5435
OPSO for fred.bin using bits 9 to 18 142237 1.130 .8707
OPSO for fred.bin using bits 8 to 17 142374 1.602 .9455
OPSO for fred.bin using bits 7 to 16 141525 -1.325 .0925
OPSO for fred.bin using bits 6 to 15 141626 -.977 .1643
OPSO for fred.bin using bits 5 to 14 141878 -.108 .4570
OPSO for fred.bin using bits 4 to 13 142159 .861 .8054
OPSO for fred.bin using bits 3 to 12 141423 -1.677 .0468
OPSO for fred.bin using bits 2 to 11 141765 -.498 .3094
OPSO for fred.bin using bits 1 to 10 141407 -1.732 .0416
OQSO test for generator fred.bin
Output: No. missing words (mw), equiv normal variate (z), p-value (p)
mw z p
OQSO for fred.bin using bits 28 to 32 141933 .080 .5320
OQSO for fred.bin using bits 27 to 31 141448 -1.564 .0589
OQSO for fred.bin using bits 26 to 30 141733 -.598 .2750
OQSO for fred.bin using bits 25 to 29 141911 .006 .5023
OQSO for fred.bin using bits 24 to 28 142050 .477 .6833
OQSO for fred.bin using bits 23 to 27 141869 -.137 .4456
OQSO for fred.bin using bits 22 to 26 141537 -1.262 .1035
OQSO for fred.bin using bits 21 to 25 141940 .104 .5414
OQSO for fred.bin using bits 20 to 24 142295 1.307 .9045
OQSO for fred.bin using bits 19 to 23 142162 .857 .8041
OQSO for fred.bin using bits 18 to 22 141187 -2.449 .0072
OQSO for fred.bin using bits 17 to 21 142059 .507 .6940
OQSO for fred.bin using bits 16 to 20 141916 .023 .5090
OQSO for fred.bin using bits 15 to 19 142172 .890 .8134
OQSO for fred.bin using bits 14 to 18 141301 -2.062 .0196
OQSO for fred.bin using bits 13 to 17 141551 -1.215 .1122
OQSO for fred.bin using bits 12 to 16 141676 -.791 .2145
OQSO for fred.bin using bits 11 to 15 141650 -.879 .1897
OQSO for fred.bin using bits 10 to 14 141752 -.533 .2969
OQSO for fred.bin using bits 9 to 13 141539 -1.255 .1047
OQSO for fred.bin using bits 8 to 12 141380 -1.794 .0364
OQSO for fred.bin using bits 7 to 11 142202 .992 .8394
OQSO for fred.bin using bits 6 to 10 141377 -1.805 .0356
OQSO for fred.bin using bits 5 to 9 141782 -.432 .3330
OQSO for fred.bin using bits 4 to 8 141628 -.954 .1701
OQSO for fred.bin using bits 3 to 7 141769 -.476 .3171
OQSO for fred.bin using bits 2 to 6 141738 -.581 .2807
OQSO for fred.bin using bits 1 to 5 141632 -.940 .1736
DNA test for generator fred.bin
Output: No. missing words (mw), equiv normal variate (z), p-value (p)
mw z p
DNA for fred.bin using bits 31 to 32 141909 -.001 .4996
DNA for fred.bin using bits 30 to 31 142132 .657 .7444
DNA for fred.bin using bits 29 to 30 141937 .082 .5325
DNA for fred.bin using bits 28 to 29 141896 -.039 .4843
DNA for fred.bin using bits 27 to 28 141887 -.066 .4737
DNA for fred.bin using bits 26 to 27 141692 -.641 .2607
DNA for fred.bin using bits 25 to 26 141538 -1.095 .1367
DNA for fred.bin using bits 24 to 25 141607 -.892 .1862
DNA for fred.bin using bits 23 to 24 141974 .191 .5756
DNA for fred.bin using bits 22 to 23 142120 .621 .7328
DNA for fred.bin using bits 21 to 22 142253 1.014 .8447
DNA for fred.bin using bits 20 to 21 141792 -.346 .3646
DNA for fred.bin using bits 19 to 20 142214 .899 .8156
DNA for fred.bin using bits 18 to 19 142304 1.164 .8778
DNA for fred.bin using bits 17 to 18 140954 -2.818 .0024
DNA for fred.bin using bits 16 to 17 141948 .114 .5454
DNA for fred.bin using bits 15 to 16 141605 -.898 .1847
DNA for fred.bin using bits 14 to 15 141941 .093 .5372
DNA for fred.bin using bits 13 to 14 142067 .465 .6791
DNA for fred.bin using bits 12 to 13 141933 .070 .5278
DNA for fred.bin using bits 11 to 12 141662 -.730 .2328
DNA for fred.bin using bits 10 to 11 141649 -.768 .2213
DNA for fred.bin using bits 9 to 10 140983 -2.733 .0031
DNA for fred.bin using bits 8 to 9 141183 -2.143 .0161
DNA for fred.bin using bits 7 to 8 141721 -.556 .2893
DNA for fred.bin using bits 6 to 7 142460 1.624 .9479
DNA for fred.bin using bits 5 to 6 141666 -.718 .2364
DNA for fred.bin using bits 4 to 5 141694 -.635 .2627
DNA for fred.bin using bits 3 to 4 142141 .683 .7528
DNA for fred.bin using bits 2 to 3 141891 -.054 .4784
DNA for fred.bin using bits 1 to 2 142392 1.424 .9227
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: This is the COUNT-THE-1's TEST on a stream of bytes. ::
:: Consider the file under test as a stream of bytes (four per ::
:: 32 bit integer). Each byte can contain from 0 to 8 1's, ::
:: with probabilities 1,8,28,56,70,56,28,8,1 over 256. Now let ::
:: the stream of bytes provide a string of overlapping 5-letter ::
:: words, each "letter" taking values A,B,C,D,E. The letters are ::
:: determined by the number of 1's in a byte:: 0,1,or 2 yield A,::
:: 3 yields B, 4 yields C, 5 yields D and 6,7 or 8 yield E. Thus ::
:: we have a monkey at a typewriter hitting five keys with vari- ::
:: ous probabilities (37,56,70,56,37 over 256). There are 5^5 ::
:: possible 5-letter words, and from a string of 256,000 (over- ::
:: lapping) 5-letter words, counts are made on the frequencies ::
:: for each word. The quadratic form in the weak inverse of ::
:: the covariance matrix of the cell counts provides a chisquare ::
:: test:: Q5-Q4, the difference of the naive Pearson sums of ::
:: (OBS-EXP)^2/EXP on counts for 5- and 4-letter cell counts. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Test results for fred.bin
Chi-square with 5^5-5^4=2500 d.of f. for sample size:2560000
chisquare equiv normal p-value
Results fo COUNT-THE-1's in successive bytes:
byte stream for fred.bin 2566.63 .942 .826985
byte stream for fred.bin 2496.90 -.044 .482493
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: This is the COUNT-THE-1's TEST for specific bytes. ::
:: Consider the file under test as a stream of 32-bit integers. ::
:: From each integer, a specific byte is chosen , say the left- ::
:: most:: bits 1 to 8. Each byte can contain from 0 to 8 1's, ::
:: with probabilitie 1,8,28,56,70,56,28,8,1 over 256. Now let ::
:: the specified bytes from successive integers provide a string ::
:: of (overlapping) 5-letter words, each "letter" taking values ::
:: A,B,C,D,E. The letters are determined by the number of 1's, ::
:: in that byte:: 0,1,or 2 ---> A, 3 ---> B, 4 ---> C, 5 ---> D,::
:: and 6,7 or 8 ---> E. Thus we have a monkey at a typewriter ::
:: hitting five keys with with various probabilities:: 37,56,70,::
:: 56,37 over 256. There are 5^5 possible 5-letter words, and ::
:: from a string of 256,000 (overlapping) 5-letter words, counts ::
:: are made on the frequencies for each word. The quadratic form ::
:: in the weak inverse of the covariance matrix of the cell ::
:: counts provides a chisquare test:: Q5-Q4, the difference of ::
:: the naive Pearson sums of (OBS-EXP)^2/EXP on counts for 5- ::
:: and 4-letter cell counts. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Chi-square with 5^5-5^4=2500 d.of f. for sample size: 256000
chisquare equiv normal p value
Results for COUNT-THE-1's in specified bytes:
bits 1 to 8 2492.13 -.111 .455668
bits 2 to 9 2582.74 1.170 .879011
bits 3 to 10 2582.62 1.168 .878684
bits 4 to 11 2503.31 .047 .518659
bits 5 to 12 2410.99 -1.259 .104048
bits 6 to 13 2523.17 .328 .628406
bits 7 to 14 2498.76 -.017 .493024
bits 8 to 15 2610.72 1.566 .941309
bits 9 to 16 2539.74 .562 .712959
bits 10 to 17 2465.55 -.487 .313060
bits 11 to 18 2589.25 1.262 .896547
bits 12 to 19 2438.48 -.870 .192136
bits 13 to 20 2451.06 -.692 .244422
bits 14 to 21 2488.44 -.164 .435060
bits 15 to 22 2451.86 -.681 .247979
bits 16 to 23 2352.23 -2.090 .018319
bits 17 to 24 2488.82 -.158 .437202
bits 18 to 25 2475.66 -.344 .365315
bits 19 to 26 2420.52 -1.124 .130489
bits 20 to 27 2561.02 .863 .805936
bits 21 to 28 2431.73 -.965 .167163
bits 22 to 29 2631.19 1.855 .968224
bits 23 to 30 2699.39 2.820 .997597
bits 24 to 31 2467.36 -.462 .322190
bits 25 to 32 2552.27 .739 .770098
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: THIS IS A PARKING LOT TEST ::
:: In a square of side 100, randomly "park" a car---a circle of ::
:: radius 1. Then try to park a 2nd, a 3rd, and so on, each ::
:: time parking "by ear". That is, if an attempt to park a car ::
:: causes a crash with one already parked, try again at a new ::
:: random location. (To avoid path problems, consider parking ::
:: helicopters rather than cars.) Each attempt leads to either ::
:: a crash or a success, the latter followed by an increment to ::
:: the list of cars already parked. If we plot n: the number of ::
:: attempts, versus k:: the number successfully parked, we get a::
:: curve that should be similar to those provided by a perfect ::
:: random number generator. Theory for the behavior of such a ::
:: random curve seems beyond reach, and as graphics displays are ::
:: not available for this battery of tests, a simple characteriz ::
:: ation of the random experiment is used: k, the number of cars ::
:: successfully parked after n=12,000 attempts. Simulation shows ::
:: that k should average 3523 with sigma 21.9 and is very close ::
:: to normally distributed. Thus (k-3523)/21.9 should be a st- ::
:: andard normal variable, which, converted to a uniform varia- ::
:: ble, provides input to a KSTEST based on a sample of 10. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
CDPARK: result of ten tests on file fred.bin
Of 12,000 tries, the average no. of successes
should be 3523 with sigma=21.9
Successes: 3497 z-score: -1.187 p-value: .117571
Successes: 3569 z-score: 2.100 p-value: .982156
Successes: 3588 z-score: 2.968 p-value: .998501
Successes: 3532 z-score: .411 p-value: .659449
Successes: 3512 z-score: -.502 p-value: .307734
Successes: 3544 z-score: .959 p-value: .831196
Successes: 3507 z-score: -.731 p-value: .232514
Successes: 3525 z-score: .091 p-value: .536382
Successes: 3521 z-score: -.091 p-value: .463618
Successes: 3495 z-score: -1.279 p-value: .100530
square size avg. no. parked sample sigma
100. 3529.000 28.883
KSTEST for the above 10: p= .535422
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: THE MINIMUM DISTANCE TEST ::
:: It does this 100 times:: choose n=8000 random points in a ::
:: square of side 10000. Find d, the minimum distance between ::
:: the (n^2-n)/2 pairs of points. If the points are truly inde- ::
:: pendent uniform, then d^2, the square of the minimum distance ::
:: should be (very close to) exponentially distributed with mean ::
:: .995 . Thus 1-exp(-d^2/.995) should be uniform on [0,1) and ::
:: a KSTEST on the resulting 100 values serves as a test of uni- ::
:: formity for random points in the square. Test numbers=0 mod 5 ::
:: are printed but the KSTEST is based on the full set of 100 ::
:: random choices of 8000 points in the 10000x10000 square. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
This is the MINIMUM DISTANCE test
for random integers in the file fred.bin
Sample no. d^2 avg equiv uni
5 .0151 .1641 .015084
10 .4085 .3654 .336690
15 .2190 .6223 .197582
20 .1396 .7533 .130945
25 .8820 .7246 .587897
30 .1736 .7280 .160065
35 1.2585 .8043 .717698
40 .5178 .7701 .405714
45 .5167 .8322 .405039
50 .4617 .7963 .371231
55 .0955 .8284 .091536
60 1.4271 .8833 .761718
65 .7987 .8912 .551898
70 1.3802 .9268 .750206
75 .0397 .8917 .039081
80 .2872 .8859 .250705
85 .9557 .8947 .617313
90 .3220 .8980 .276481
95 1.7862 .9105 .833904
100 .4379 .8987 .356060
MINIMUM DISTANCE TEST for fred.bin
Result of KS test on 20 transformed mindist^2's:
p-value= .137524
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: THE 3DSPHERES TEST ::
:: Choose 4000 random points in a cube of edge 1000. At each ::
:: point, center a sphere large enough to reach the next closest ::
:: point. Then the volume of the smallest such sphere is (very ::
:: close to) exponentially distributed with mean 120pi/3. Thus ::
:: the radius cubed is exponential with mean 30. (The mean is ::
:: obtained by extensive simulation). The 3DSPHERES test gener- ::
:: ates 4000 such spheres 20 times. Each min radius cubed leads ::
:: to a uniform variable by means of 1-exp(-r^3/30.), then a ::
:: KSTEST is done on the 20 p-values. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
The 3DSPHERES test for file fred.bin
sample no: 1 r^3= 59.394 p-value= .86190
sample no: 2 r^3= 44.802 p-value= .77540
sample no: 3 r^3= 82.570 p-value= .93622
sample no: 4 r^3= 5.725 p-value= .17373
sample no: 5 r^3= 49.439 p-value= .80756
sample no: 6 r^3= 8.307 p-value= .24186
sample no: 7 r^3= 50.808 p-value= .81614
sample no: 8 r^3= 1.641 p-value= .05322
sample no: 9 r^3= 120.234 p-value= .98183
sample no: 10 r^3= 5.661 p-value= .17196
sample no: 11 r^3= 21.693 p-value= .51475
sample no: 12 r^3= 54.485 p-value= .83735
sample no: 13 r^3= 42.557 p-value= .75794
sample no: 14 r^3= 1.322 p-value= .04310
sample no: 15 r^3= 10.179 p-value= .28773
sample no: 16 r^3= 8.016 p-value= .23447
sample no: 17 r^3= 14.782 p-value= .38906
sample no: 18 r^3= 20.500 p-value= .49506
sample no: 19 r^3= 46.594 p-value= .78842
sample no: 20 r^3= 16.919 p-value= .43106
A KS test is applied to those 20 p-values.
---------------------------------------------------------
3DSPHERES test for file fred.bin p-value= .250296
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: This is the SQEEZE test ::
:: Random integers are floated to get uniforms on [0,1). Start- ::
:: ing with k=2^31=2147483647, the test finds j, the number of ::
:: iterations necessary to reduce k to 1, using the reduction ::
:: k=ceiling(k*U), with U provided by floating integers from ::
:: the file being tested. Such j's are found 100,000 times, ::
:: then counts for the number of times j was <=6,7,...,47,>=48 ::
:: are used to provide a chi-square test for cell frequencies. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
RESULTS OF SQUEEZE TEST FOR fred.bin
Table of standardized frequency counts
( (obs-exp)/sqrt(exp) )^2
for j taking values <=6,7,8,...,47,>=48:
-.1 1.8 2.5 .8 -1.5 -.5
-.2 1.5 .8 -.1 .0 1.1
-.4 .2 .3 -.4 -.8 -.3
1.8 1.4 -.1 -2.6 -.2 -.6
.4 .2 -.5 -.8 -.7 .6
-1.6 .4 .0 .3 -.2 1.3
.5 1.1 -.8 -.7 .9 1.0
.8
Chi-square with 42 degrees of freedom: 41.844
z-score= -.017 p-value= .522200
______________________________________________________________
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: The OVERLAPPING SUMS test ::
:: Integers are floated to get a sequence U(1),U(2),... of uni- ::
:: form [0,1) variables. Then overlapping sums, ::
:: S(1)=U(1)+...+U(100), S2=U(2)+...+U(101),... are formed. ::
:: The S's are virtually normal with a certain covariance mat- ::
:: rix. A linear transformation of the S's converts them to a ::
:: sequence of independent standard normals, which are converted ::
:: to uniform variables for a KSTEST. The p-values from ten ::
:: KSTESTs are given still another KSTEST. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Test no. 1 p-value .863128
Test no. 2 p-value .098562
Test no. 3 p-value .284121
Test no. 4 p-value .529716
Test no. 5 p-value .808814
Test no. 6 p-value .688140
Test no. 7 p-value .827999
Test no. 8 p-value .418933
Test no. 9 p-value .654142
Test no. 10 p-value .440693
Results of the OSUM test for fred.bin
KSTEST on the above 10 p-values: .305182
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: This is the RUNS test. It counts runs up, and runs down, ::
:: in a sequence of uniform [0,1) variables, obtained by float- ::
:: ing the 32-bit integers in the specified file. This example ::
:: shows how runs are counted: .123,.357,.789,.425,.224,.416,.95::
:: contains an up-run of length 3, a down-run of length 2 and an ::
:: up-run of (at least) 2, depending on the next values. The ::
:: covariance matrices for the runs-up and runs-down are well ::
:: known, leading to chisquare tests for quadratic forms in the ::
:: weak inverses of the covariance matrices. Runs are counted ::
:: for sequences of length 10,000. This is done ten times. Then ::
:: repeated. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
The RUNS test for file fred.bin
Up and down runs in a sample of 10000
_________________________________________________
Run test for fred.bin :
runs up; ks test for 10 p's: .550378
runs down; ks test for 10 p's: .027448
Run test for fred.bin :
runs up; ks test for 10 p's: .881194
runs down; ks test for 10 p's: .496592
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: This is the CRAPS TEST. It plays 200,000 games of craps, finds::
:: the number of wins and the number of throws necessary to end ::
:: each game. The number of wins should be (very close to) a ::
:: normal with mean 200000p and variance 200000p(1-p), with ::
:: p=244/495. Throws necessary to complete the game can vary ::
:: from 1 to infinity, but counts for all>21 are lumped with 21. ::
:: A chi-square test is made on the no.-of-throws cell counts. ::
:: Each 32-bit integer from the test file provides the value for ::
:: the throw of a die, by floating to [0,1), multiplying by 6 ::
:: and taking 1 plus the integer part of the result. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Results of craps test for fred.bin
No. of wins: Observed Expected
98556 98585.86
98556= No. of wins, z-score= -.134 pvalue= .44688
Analysis of Throws-per-Game:
Chisq= 19.56 for 20 degrees of freedom, p= .51452
Throws Observed Expected Chisq Sum
1 67136 66666.7 3.304 3.304
2 37553 37654.3 .273 3.577
3 26761 26954.7 1.392 4.969
4 19475 19313.5 1.351 6.320
5 13718 13851.4 1.285 7.605
6 9896 9943.5 .227 7.833
7 7020 7145.0 2.188 10.020
8 5042 5139.1 1.834 11.854
9 3773 3699.9 1.446 13.300
10 2615 2666.3 .987 14.286
11 1940 1923.3 .145 14.431
12 1396 1388.7 .038 14.469
13 1044 1003.7 1.617 16.086
14 751 726.1 .851 16.937
15 520 525.8 .065 17.002
16 389 381.2 .162 17.163
17 268 276.5 .264 17.427
18 186 200.8 1.095 18.522
19 139 146.0 .334 18.856
20 105 106.2 .014 18.870
21 273 287.1 .694 19.564
SUMMARY FOR fred.bin
p-value for no. of wins: .446880
p-value for throws/game: .514523
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Results of DIEHARD battery of tests sent to file fred.out