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 binary
For a sample of size 500: mean
binary using bits 1 to 24 1.962
duplicate number number
spacings observed expected
0 66. 67.668
1 141. 135.335
2 136. 135.335
3 88. 90.224
4 50. 45.112
5 14. 18.045
6 to INF 5. 8.282
Chisquare with 6 d.o.f. = 3.07 p-value= .200375
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
binary using bits 2 to 25 1.996
duplicate number number
spacings observed expected
0 72. 67.668
1 140. 135.335
2 122. 135.335
3 88. 90.224
4 50. 45.112
5 21. 18.045
6 to INF 7. 8.282
Chisquare with 6 d.o.f. = 3.02 p-value= .193545
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
binary using bits 3 to 26 1.930
duplicate number number
spacings observed expected
0 70. 67.668
1 148. 135.335
2 126. 135.335
3 91. 90.224
4 40. 45.112
5 21. 18.045
6 to INF 4. 8.282
Chisquare with 6 d.o.f. = 5.19 p-value= .480713
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
binary using bits 4 to 27 1.922
duplicate number number
spacings observed expected
0 70. 67.668
1 143. 135.335
2 134. 135.335
3 85. 90.224
4 51. 45.112
5 11. 18.045
6 to INF 6. 8.282
Chisquare with 6 d.o.f. = 4.98 p-value= .453311
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
binary using bits 5 to 28 1.988
duplicate number number
spacings observed expected
0 71. 67.668
1 134. 135.335
2 139. 135.335
3 83. 90.224
4 45. 45.112
5 18. 18.045
6 to INF 10. 8.282
Chisquare with 6 d.o.f. = 1.21 p-value= .023697
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
binary using bits 6 to 29 1.980
duplicate number number
spacings observed expected
0 69. 67.668
1 147. 135.335
2 120. 135.335
3 91. 90.224
4 49. 45.112
5 16. 18.045
6 to INF 8. 8.282
Chisquare with 6 d.o.f. = 3.35 p-value= .236510
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
binary using bits 7 to 30 2.008
duplicate number number
spacings observed expected
0 73. 67.668
1 135. 135.335
2 134. 135.335
3 83. 90.224
4 46. 45.112
5 12. 18.045
6 to INF 17. 8.282
Chisquare with 6 d.o.f. = 12.23 p-value= .943021
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
binary using bits 8 to 31 2.026
duplicate number number
spacings observed expected
0 59. 67.668
1 136. 135.335
2 135. 135.335
3 101. 90.224
4 47. 45.112
5 17. 18.045
6 to INF 5. 8.282
Chisquare with 6 d.o.f. = 3.84 p-value= .301885
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
binary using bits 9 to 32 2.088
duplicate number number
spacings observed expected
0 59. 67.668
1 130. 135.335
2 129. 135.335
3 100. 90.224
4 58. 45.112
5 21. 18.045
6 to INF 3. 8.282
Chisquare with 6 d.o.f. = 10.21 p-value= .883963
:::::::::::::::::::::::::::::::::::::::::
The 9 p-values were
.200375 .193545 .480713 .453311 .023697
.236510 .943021 .301885 .883963
A KSTEST for the 9 p-values yields .521097
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 binary
For a sample of 1,000,000 consecutive 5-tuples,
chisquare for 99 degrees of freedom= 94.339; p-value= .386226
OPERM5 test for file binary
For a sample of 1,000,000 consecutive 5-tuples,
chisquare for 99 degrees of freedom= 90.679; p-value= .287284
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 binary
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 220 211.4 .348364 .348
29 5019 5134.0 2.576418 2.925
30 23218 23103.0 .571969 3.497
31 11543 11551.5 .006291 3.503
chisquare= 3.503 for 3 d. of f.; p-value= .710261
--------------------------------------------------------------
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 binary
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 205 211.4 .194832 .195
30 5176 5134.0 .343423 .538
31 23092 23103.0 .005282 .544
32 11527 11551.5 .052066 .596
chisquare= .596 for 3 d. of f.; p-value= .322693
--------------------------------------------------------------
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 binary
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 1 to 8
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 926 944.3 .355 .355
r =5 21996 21743.9 2.923 3.278
r =6 77078 77311.8 .707 3.985
p=1-exp(-SUM/2)= .86362
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 2 to 9
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 898 944.3 2.270 2.270
r =5 21640 21743.9 .496 2.767
r =6 77462 77311.8 .292 3.059
p=1-exp(-SUM/2)= .78330
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 3 to 10
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 940 944.3 .020 .020
r =5 21865 21743.9 .674 .694
r =6 77195 77311.8 .176 .871
p=1-exp(-SUM/2)= .35290
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 4 to 11
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 921 944.3 .575 .575
r =5 22077 21743.9 5.103 5.678
r =6 77002 77311.8 1.241 6.919
p=1-exp(-SUM/2)= .96856
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 5 to 12
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 985 944.3 1.754 1.754
r =5 21742 21743.9 .000 1.754
r =6 77273 77311.8 .019 1.774
p=1-exp(-SUM/2)= .58805
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 6 to 13
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 927 944.3 .317 .317
r =5 21751 21743.9 .002 .319
r =6 77322 77311.8 .001 .321
p=1-exp(-SUM/2)= .14813
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 7 to 14
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 911 944.3 1.174 1.174
r =5 21933 21743.9 1.645 2.819
r =6 77156 77311.8 .314 3.133
p=1-exp(-SUM/2)= .79122
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 8 to 15
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 908 944.3 1.396 1.396
r =5 21813 21743.9 .220 1.615
r =6 77279 77311.8 .014 1.629
p=1-exp(-SUM/2)= .55714
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 9 to 16
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 909 944.3 1.320 1.320
r =5 21663 21743.9 .301 1.621
r =6 77428 77311.8 .175 1.795
p=1-exp(-SUM/2)= .59248
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 10 to 17
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 905 944.3 1.636 1.636
r =5 21829 21743.9 .333 1.969
r =6 77266 77311.8 .027 1.996
p=1-exp(-SUM/2)= .63136
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 11 to 18
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 896 944.3 2.471 2.471
r =5 21862 21743.9 .641 3.112
r =6 77242 77311.8 .063 3.175
p=1-exp(-SUM/2)= .79557
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 12 to 19
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 930 944.3 .217 .217
r =5 21785 21743.9 .078 .294
r =6 77285 77311.8 .009 .304
p=1-exp(-SUM/2)= .14083
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 13 to 20
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 898 944.3 2.270 2.270
r =5 21683 21743.9 .171 2.441
r =6 77419 77311.8 .149 2.589
p=1-exp(-SUM/2)= .72603
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 14 to 21
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 905 944.3 1.636 1.636
r =5 21844 21743.9 .461 2.097
r =6 77251 77311.8 .048 2.144
p=1-exp(-SUM/2)= .65773
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 15 to 22
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 944 944.3 .000 .000
r =5 21724 21743.9 .018 .018
r =6 77332 77311.8 .005 .024
p=1-exp(-SUM/2)= .01172
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 16 to 23
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 976 944.3 1.064 1.064
r =5 21829 21743.9 .333 1.397
r =6 77195 77311.8 .176 1.574
p=1-exp(-SUM/2)= .54470
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 17 to 24
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 945 944.3 .001 .001
r =5 21761 21743.9 .013 .014
r =6 77294 77311.8 .004 .018
p=1-exp(-SUM/2)= .00899
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 18 to 25
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 902 944.3 1.895 1.895
r =5 21918 21743.9 1.394 3.289
r =6 77180 77311.8 .225 3.514
p=1-exp(-SUM/2)= .82741
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 19 to 26
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 897 944.3 2.369 2.369
r =5 21844 21743.9 .461 2.830
r =6 77259 77311.8 .036 2.866
p=1-exp(-SUM/2)= .76144
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 20 to 27
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 985 944.3 1.754 1.754
r =5 21730 21743.9 .009 1.763
r =6 77285 77311.8 .009 1.772
p=1-exp(-SUM/2)= .58775
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 21 to 28
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 932 944.3 .160 .160
r =5 21828 21743.9 .325 .486
r =6 77240 77311.8 .067 .552
p=1-exp(-SUM/2)= .24127
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 22 to 29
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 948 944.3 .014 .014
r =5 21629 21743.9 .607 .622
r =6 77423 77311.8 .160 .782
p=1-exp(-SUM/2)= .32348
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 23 to 30
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 942 944.3 .006 .006
r =5 21791 21743.9 .102 .108
r =6 77267 77311.8 .026 .134
p=1-exp(-SUM/2)= .06462
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 24 to 31
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 957 944.3 .171 .171
r =5 21789 21743.9 .094 .264
r =6 77254 77311.8 .043 .308
p=1-exp(-SUM/2)= .14253
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG binary
b-rank test for bits 25 to 32
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 946 944.3 .003 .003
r =5 21640 21743.9 .496 .500
r =6 77414 77311.8 .135 .635
p=1-exp(-SUM/2)= .27189
TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices
These should be 25 uniform [0,1] random variables:
.863619 .783304 .352901 .968558 .588055
.148134 .791216 .557144 .592477 .631364
.795574 .140826 .726028 .657734 .011723
.544702 .008992 .827407 .761439 .587753
.241267 .323478 .064616 .142527 .271894
brank test summary for binary
The KS test for those 25 supposed UNI's yields
KS p-value= .266739
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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: 142172 missing words, .61 sigmas from mean, p-value= .73030
tst no 2: 142341 missing words, 1.01 sigmas from mean, p-value= .84341
tst no 3: 142092 missing words, .43 sigmas from mean, p-value= .66524
tst no 4: 141765 missing words, -.34 sigmas from mean, p-value= .36798
tst no 5: 142178 missing words, .63 sigmas from mean, p-value= .73491
tst no 6: 141554 missing words, -.83 sigmas from mean, p-value= .20321
tst no 7: 142502 missing words, 1.38 sigmas from mean, p-value= .91694
tst no 8: 142320 missing words, .96 sigmas from mean, p-value= .83135
tst no 9: 141299 missing words, -1.43 sigmas from mean, p-value= .07693
tst no 10: 141458 missing words, -1.05 sigmas from mean, p-value= .14583
tst no 11: 142219 missing words, .72 sigmas from mean, p-value= .76532
tst no 12: 142181 missing words, .63 sigmas from mean, p-value= .73720
tst no 13: 141230 missing words, -1.59 sigmas from mean, p-value= .05623
tst no 14: 141949 missing words, .09 sigmas from mean, p-value= .53693
tst no 15: 142058 missing words, .35 sigmas from mean, p-value= .63584
tst no 16: 141979 missing words, .16 sigmas from mean, p-value= .56466
tst no 17: 141559 missing words, -.82 sigmas from mean, p-value= .20653
tst no 18: 141493 missing words, -.97 sigmas from mean, p-value= .16534
tst no 19: 141944 missing words, .08 sigmas from mean, p-value= .53228
tst no 20: 142093 missing words, .43 sigmas from mean, p-value= .66609
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 binary
Output: No. missing words (mw), equiv normal variate (z), p-value (p)
mw z p
OPSO for binary using bits 23 to 32 142007 .337 .6319
OPSO for binary using bits 22 to 31 141718 -.660 .2547
OPSO for binary using bits 21 to 30 141755 -.532 .2973
OPSO for binary using bits 20 to 29 141865 -.153 .4393
OPSO for binary using bits 19 to 28 141766 -.494 .3106
OPSO for binary using bits 18 to 27 142096 .644 .7401
OPSO for binary using bits 17 to 26 141680 -.791 .2145
OPSO for binary using bits 16 to 25 141833 -.263 .3962
OPSO for binary using bits 15 to 24 141957 .164 .5653
OPSO for binary using bits 14 to 23 141530 -1.308 .0954
OPSO for binary using bits 13 to 22 141535 -1.291 .0984
OPSO for binary using bits 12 to 21 141670 -.825 .2046
OPSO for binary using bits 11 to 20 141799 -.380 .3518
OPSO for binary using bits 10 to 19 141609 -1.036 .1502
OPSO for binary using bits 9 to 18 141894 -.053 .4789
OPSO for binary using bits 8 to 17 141841 -.236 .4069
OPSO for binary using bits 7 to 16 141758 -.522 .3009
OPSO for binary using bits 6 to 15 141691 -.753 .2258
OPSO for binary using bits 5 to 14 141929 .068 .5270
OPSO for binary using bits 4 to 13 141882 -.094 .4625
OPSO for binary using bits 3 to 12 141918 .030 .5119
OPSO for binary using bits 2 to 11 141995 .295 .6162
OPSO for binary using bits 1 to 10 141550 -1.239 .1077
OQSO test for generator binary
Output: No. missing words (mw), equiv normal variate (z), p-value (p)
mw z p
OQSO for binary using bits 28 to 32 142048 .470 .6808
OQSO for binary using bits 27 to 31 142091 .616 .7310
OQSO for binary using bits 26 to 30 142010 .341 .6335
OQSO for binary using bits 25 to 29 141372 -1.821 .0343
OQSO for binary using bits 24 to 28 141781 -.435 .3318
OQSO for binary using bits 23 to 27 141941 .107 .5427
OQSO for binary using bits 22 to 26 141942 .111 .5441
OQSO for binary using bits 21 to 25 141800 -.371 .3555
OQSO for binary using bits 20 to 24 142250 1.155 .8759
OQSO for binary using bits 19 to 23 141458 -1.530 .0630
OQSO for binary using bits 18 to 22 142075 .562 .7128
OQSO for binary using bits 17 to 21 141935 .087 .5347
OQSO for binary using bits 16 to 20 142156 .836 .7985
OQSO for binary using bits 15 to 19 142071 .548 .7082
OQSO for binary using bits 14 to 18 141873 -.123 .4510
OQSO for binary using bits 13 to 17 142032 .416 .6612
OQSO for binary using bits 12 to 16 141990 .273 .6078
OQSO for binary using bits 11 to 15 142369 1.558 .9404
OQSO for binary using bits 10 to 14 141866 -.147 .4416
OQSO for binary using bits 9 to 13 141761 -.503 .3075
OQSO for binary using bits 8 to 12 142050 .477 .6833
OQSO for binary using bits 7 to 11 142068 .538 .7047
OQSO for binary using bits 6 to 10 141725 -.625 .2660
OQSO for binary using bits 5 to 9 142421 1.734 .9586
OQSO for binary using bits 4 to 8 142145 .799 .7878
OQSO for binary using bits 3 to 7 142267 1.212 .8873
OQSO for binary using bits 2 to 6 142199 .982 .8369
OQSO for binary using bits 1 to 5 142036 .429 .6662
DNA test for generator binary
Output: No. missing words (mw), equiv normal variate (z), p-value (p)
mw z p
DNA for binary using bits 31 to 32 142043 .394 .6533
DNA for binary using bits 30 to 31 142565 1.934 .9735
DNA for binary using bits 29 to 30 141904 -.016 .4937
DNA for binary using bits 28 to 29 141927 .052 .5208
DNA for binary using bits 27 to 28 142439 1.562 .9409
DNA for binary using bits 26 to 27 141319 -1.741 .0408
DNA for binary using bits 25 to 26 142261 1.037 .8502
DNA for binary using bits 24 to 25 141790 -.352 .3624
DNA for binary using bits 23 to 24 141511 -1.175 .1200
DNA for binary using bits 22 to 23 142288 1.117 .8680
DNA for binary using bits 21 to 22 141591 -.939 .1739
DNA for binary using bits 20 to 21 142353 1.309 .9047
DNA for binary using bits 19 to 20 142021 .329 .6291
DNA for binary using bits 18 to 19 141751 -.467 .3202
DNA for binary using bits 17 to 18 142314 1.194 .8837
DNA for binary using bits 16 to 17 141466 -1.308 .0955
DNA for binary using bits 15 to 16 141675 -.691 .2447
DNA for binary using bits 14 to 15 142034 .368 .6435
DNA for binary using bits 13 to 14 141690 -.647 .2588
DNA for binary using bits 12 to 13 141961 .152 .5606
DNA for binary using bits 11 to 12 142081 .506 .6937
DNA for binary using bits 10 to 11 142231 .949 .8287
DNA for binary using bits 9 to 10 142005 .282 .6111
DNA for binary using bits 8 to 9 141692 -.641 .2607
DNA for binary using bits 7 to 8 141230 -2.004 .0225
DNA for binary using bits 6 to 7 141935 .076 .5302
DNA for binary using bits 5 to 6 141995 .253 .5998
DNA for binary using bits 4 to 5 142067 .465 .6791
DNA for binary using bits 3 to 4 142023 .335 .6313
DNA for binary using bits 2 to 3 141966 .167 .5664
DNA for binary using bits 1 to 2 141365 -1.606 .0542
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 binary
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 binary 2450.49 -.700 .241902
byte stream for binary 2430.05 -.989 .161275
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 2544.33 .627 .734656
bits 2 to 9 2540.48 .572 .716495
bits 3 to 10 2443.45 -.800 .211920
bits 4 to 11 2525.71 .364 .641920
bits 5 to 12 2584.63 1.197 .884306
bits 6 to 13 2403.11 -1.370 .085318
bits 7 to 14 2508.51 .120 .547881
bits 8 to 15 2489.07 -.155 .438558
bits 9 to 16 2599.47 1.407 .920255
bits 10 to 17 2473.42 -.376 .353477
bits 11 to 18 2496.29 -.052 .479099
bits 12 to 19 2518.13 .256 .601192
bits 13 to 20 2506.35 .090 .535768
bits 14 to 21 2586.00 1.216 .888062
bits 15 to 22 2494.98 -.071 .471713
bits 16 to 23 2662.68 2.301 .989294
bits 17 to 24 2442.04 -.820 .206198
bits 18 to 25 2505.13 .073 .528945
bits 19 to 26 2502.99 .042 .516881
bits 20 to 27 2454.63 -.642 .260571
bits 21 to 28 2582.71 1.170 .878952
bits 22 to 29 2478.91 -.298 .382752
bits 23 to 30 2449.49 -.714 .237523
bits 24 to 31 2383.66 -1.645 .049950
bits 25 to 32 2457.28 -.604 .272883
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 binary
Of 12,000 tries, the average no. of successes
should be 3523 with sigma=21.9
Successes: 3543 z-score: .913 p-value: .819442
Successes: 3503 z-score: -.913 p-value: .180558
Successes: 3527 z-score: .183 p-value: .572463
Successes: 3550 z-score: 1.233 p-value: .891189
Successes: 3525 z-score: .091 p-value: .536382
Successes: 3507 z-score: -.731 p-value: .232514
Successes: 3530 z-score: .320 p-value: .625377
Successes: 3520 z-score: -.137 p-value: .445521
Successes: 3529 z-score: .274 p-value: .607947
Successes: 3517 z-score: -.274 p-value: .392053
square size avg. no. parked sample sigma
100. 3525.100 13.755
KSTEST for the above 10: p= .312483
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 binary
Sample no. d^2 avg equiv uni
5 2.0244 .7676 .869265
10 .4252 .7275 .347736
15 1.4989 .8872 .778301
20 .4020 .8280 .332354
25 2.2612 .8433 .896957
30 2.2129 .9765 .891824
35 6.1000 1.0713 .997825
40 1.9203 1.0599 .854851
45 1.9095 1.0270 .853267
50 .0672 1.0376 .065309
55 .6964 1.0861 .503371
60 .7904 1.0687 .548125
65 1.8572 1.0578 .845345
70 2.2701 1.1034 .897874
75 2.4887 1.1165 .918012
80 .7276 1.0902 .518711
85 .2275 1.0750 .204400
90 .2947 1.0491 .256336
95 .9216 1.1573 .603946
100 .2677 1.1247 .235861
MINIMUM DISTANCE TEST for binary
Result of KS test on 20 transformed mindist^2's:
p-value= .553392
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 binary
sample no: 1 r^3= 3.758 p-value= .11775
sample no: 2 r^3= 13.912 p-value= .37107
sample no: 3 r^3= 90.888 p-value= .95166
sample no: 4 r^3= 20.729 p-value= .49892
sample no: 5 r^3= 8.794 p-value= .25407
sample no: 6 r^3= 5.392 p-value= .16451
sample no: 7 r^3= 33.898 p-value= .67695
sample no: 8 r^3= 40.404 p-value= .73993
sample no: 9 r^3= 6.986 p-value= .20774
sample no: 10 r^3= 25.473 p-value= .57220
sample no: 11 r^3= 34.403 p-value= .68234
sample no: 12 r^3= 3.198 p-value= .10111
sample no: 13 r^3= 41.804 p-value= .75178
sample no: 14 r^3= .246 p-value= .00818
sample no: 15 r^3= 10.488 p-value= .29503
sample no: 16 r^3= 116.260 p-value= .97925
sample no: 17 r^3= 10.978 p-value= .30646
sample no: 18 r^3= 63.977 p-value= .88147
sample no: 19 r^3= .895 p-value= .02941
sample no: 20 r^3= 8.948 p-value= .25789
A KS test is applied to those 20 p-values.
---------------------------------------------------------
3DSPHERES test for file binary p-value= .429715
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 binary
Table of standardized frequency counts
( (obs-exp)/sqrt(exp) )^2
for j taking values <=6,7,8,...,47,>=48:
-1.5 -.3 1.1 .0 .9 -.6
2.0 .0 -.3 -.8 .7 -.6
-1.2 -.1 .5 -1.7 .5 -.4
-1.9 .2 2.9 .5 -.4 .3
.4 .5 .5 1.7 -2.7 .7
.7 -.5 1.1 -.5 .9 .4
1.7 1.5 -.8 -1.3 .1 .0
.8
Chi-square with 42 degrees of freedom: 49.438
z-score= .812 p-value= .799709
______________________________________________________________
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 .591068
Test no. 2 p-value .334507
Test no. 3 p-value .655834
Test no. 4 p-value .442867
Test no. 5 p-value .314904
Test no. 6 p-value .029688
Test no. 7 p-value .286477
Test no. 8 p-value .169817
Test no. 9 p-value .547046
Test no. 10 p-value .613154
Results of the OSUM test for binary
KSTEST on the above 10 p-values: .710285
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 binary
Up and down runs in a sample of 10000
_________________________________________________
Run test for binary :
runs up; ks test for 10 p's: .434613
runs down; ks test for 10 p's: .347954
Run test for binary :
runs up; ks test for 10 p's: .033966
runs down; ks test for 10 p's: .233282
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 binary
No. of wins: Observed Expected
98864 98585.86
98864= No. of wins, z-score= 1.244 pvalue= .89325
Analysis of Throws-per-Game:
Chisq= 15.33 for 20 degrees of freedom, p= .24287
Throws Observed Expected Chisq Sum
1 67193 66666.7 4.155 4.155
2 37507 37654.3 .576 4.732
3 26915 26954.7 .059 4.790
4 19209 19313.5 .565 5.355
5 13651 13851.4 2.900 8.255
6 9832 9943.5 1.251 9.506
7 7194 7145.0 .336 9.842
8 5109 5139.1 .176 10.018
9 3739 3699.9 .414 10.432
10 2697 2666.3 .354 10.786
11 1935 1923.3 .071 10.856
12 1416 1388.7 .535 11.392
13 988 1003.7 .246 11.638
14 733 726.1 .065 11.702
15 519 525.8 .089 11.791
16 361 381.2 1.065 12.857
17 272 276.5 .075 12.931
18 216 200.8 1.146 14.077
19 139 146.0 .334 14.411
20 99 106.2 .490 14.901
21 276 287.1 .430 15.332
SUMMARY FOR binary
p-value for no. of wins: .893252
p-value for throws/game: .242868
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Results of DIEHARD battery of tests sent to file binary.txt