WE TOOK A RANDOM.DAT
FILE OF ABOUT 12.5 MB GENERATED BY REALLY RANDOM
NUMBERS AND RAN SOME OF THE COMMONLY AVAILABLE AND MOST STRINGENT RANDOM
NUMBER TESTS ON THE WEB ON IT. THE RESULTS ARE SHOWN BELOW.
WHEN YOU COMPARE TO RESULTS FROM THE C++ RAND() FUNCTION, YOU
WILL FIND
REALLY RANDOM NUMBERS OUTPERFORMS SIGNIFICANTLY ON VIRTUALLY ALL
RANDOMNESS TESTS.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: TEST RESULTS FROM ENT.EXE ::
:: http://www.fourmilab.ch/random/ ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Entropy = 7.999986 bits per byte.
Optimum compression would reduce the size
of this 12750000 byte file by 0 percent.
Chi square distribution for 12750000 samples is 245.97, and
randomly
would exceed this value 50.00 percent of the times.
Arithmetic mean value of data bytes is 127.4865 (127.5 = random).
Monte Carlo value for Pi is 3.142439529 (error 0.03 percent).
Serial correlation coefficient is 0.000186 (totally uncorrelated = 0.0).
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: TEST RESULTS FROM DIEHARD.EXE ::
:: http://stat.fsu.edu/~geo/diehard.html ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
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 RANDOM.DAT
For a sample of size 500: mean
RANDOM.DAT using bits 1 to 24 1.968
duplicate number number
spacings observed expected
0 61. 67.668
1 141. 135.335
2 135. 135.335
3 112. 90.224
4 28. 45.112
5 15. 18.045
6 to INF 8. 8.282
Chisquare with 6 d.o.f. = 13.17 p-value= .959512
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 2 to 25 1.988
duplicate number number
spacings observed expected
0 58. 67.668
1 142. 135.335
2 138. 135.335
3 95. 90.224
4 50. 45.112
5 12. 18.045
6 to INF 5. 8.282
Chisquare with 6 d.o.f. = 5.87 p-value= .562068
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 3 to 26 2.046
duplicate number number
spacings observed expected
0 66. 67.668
1 124. 135.335
2 147. 135.335
3 92. 90.224
4 41. 45.112
5 18. 18.045
6 to INF 12. 8.282
Chisquare with 6 d.o.f. = 4.08 p-value= .333483
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 4 to 27 2.026
duplicate number number
spacings observed expected
0 65. 67.668
1 137. 135.335
2 134. 135.335
3 88. 90.224
4 47. 45.112
5 20. 18.045
6 to INF 9. 8.282
Chisquare with 6 d.o.f. = .55 p-value= .002779
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 5 to 28 2.008
duplicate number number
spacings observed expected
0 71. 67.668
1 130. 135.335
2 148. 135.335
3 73. 90.224
4 51. 45.112
5 15. 18.045
6 to INF 12. 8.282
Chisquare with 6 d.o.f. = 7.80 p-value= .746810
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 6 to 29 2.074
duplicate number number
spacings observed expected
0 56. 67.668
1 140. 135.335
2 119. 135.335
3 108. 90.224
4 55. 45.112
5 18. 18.045
6 to INF 4. 8.282
Chisquare with 6 d.o.f. = 12.03 p-value= .938654
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 7 to 30 1.948
duplicate number number
spacings observed expected
0 74. 67.668
1 126. 135.335
2 149. 135.335
3 88. 90.224
4 35. 45.112
5 22. 18.045
6 to INF 6. 8.282
Chisquare with 6 d.o.f. = 6.43 p-value= .623554
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 8 to 31 1.976
duplicate number number
spacings observed expected
0 74. 67.668
1 138. 135.335
2 126. 135.335
3 84. 90.224
4 57. 45.112
5 11. 18.045
6 to INF 10. 8.282
Chisquare with 6 d.o.f. = 7.96 p-value= .758797
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 9 to 32 1.948
duplicate number number
spacings observed expected
0 72. 67.668
1 155. 135.335
2 111. 135.335
3 86. 90.224
4 51. 45.112
5 17. 18.045
6 to INF 8. 8.282
Chisquare with 6 d.o.f. = 8.55 p-value= .799293
:::::::::::::::::::::::::::::::::::::::::
The 9 p-values were
.959512 .562068 .333483 .002779 .746810
.938654 .623554 .758797 .799293
A KSTEST for the 9 p-values yields .839674
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
For a sample of 1,000,000 consecutive 5-tuples,
chisquare for 99 degrees of freedom=117.976; p-value= .906231
OPERM5 test for file RANDOM.DAT
For a sample of 1,000,000 consecutive 5-tuples,
chisquare for 99 degrees of freedom=120.491; p-value= .930004
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
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 221 211.4 .434279 .434
29 5146 5134.0 .028000 .462
30 23062 23103.0 .072927 .535
31 11571 11551.5 .032835 .568
chisquare= .568 for 3 d. of f.; p-value= .321812
--------------------------------------------------------------
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
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 191 211.4 1.971901 1.972
30 5096 5134.0 .281413 2.253
31 23132 23103.0 .036285 2.290
32 11581 11551.5 .075212 2.365
chisquare= 2.365 for 3 d. of f.; p-value= .561831
--------------------------------------------------------------
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 1 to 8
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 950 944.3 .034 .034
r =5 21879 21743.9 .839 .874
r =6 77171 77311.8 .256 1.130
p=1-exp(-SUM/2)= .43171
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 2 to 9
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 978 944.3 1.203 1.203
r =5 21693 21743.9 .119 1.322
r =6 77329 77311.8 .004 1.326
p=1-exp(-SUM/2)= .48458
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 3 to 10
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 954 944.3 .100 .100
r =5 21663 21743.9 .301 .401
r =6 77383 77311.8 .066 .466
p=1-exp(-SUM/2)= .20792
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 4 to 11
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 959 944.3 .229 .229
r =5 21653 21743.9 .380 .609
r =6 77388 77311.8 .075 .684
p=1-exp(-SUM/2)= .28962
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 5 to 12
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 930 944.3 .217 .217
r =5 21720 21743.9 .026 .243
r =6 77350 77311.8 .019 .262
p=1-exp(-SUM/2)= .12266
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 6 to 13
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 946 944.3 .003 .003
r =5 21453 21743.9 3.892 3.895
r =6 77601 77311.8 1.082 4.977
p=1-exp(-SUM/2)= .91695
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 7 to 14
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 936 944.3 .073 .073
r =5 21647 21743.9 .432 .505
r =6 77417 77311.8 .143 .648
p=1-exp(-SUM/2)= .27673
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 8 to 15
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 973 944.3 .872 .872
r =5 21715 21743.9 .038 .911
r =6 77312 77311.8 .000 .911
p=1-exp(-SUM/2)= .36575
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 9 to 16
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 946 944.3 .003 .003
r =5 21692 21743.9 .124 .127
r =6 77362 77311.8 .033 .160
p=1-exp(-SUM/2)= .07667
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 10 to 17
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 957 944.3 .171 .171
r =5 21642 21743.9 .478 .648
r =6 77401 77311.8 .103 .751
p=1-exp(-SUM/2)= .31313
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 11 to 18
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 941 944.3 .012 .012
r =5 21702 21743.9 .081 .092
r =6 77357 77311.8 .026 .119
p=1-exp(-SUM/2)= .05762
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 12 to 19
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 979 944.3 1.275 1.275
r =5 21909 21743.9 1.254 2.529
r =6 77112 77311.8 .516 3.045
p=1-exp(-SUM/2)= .78183
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 13 to 20
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 991 944.3 2.309 2.309
r =5 21737 21743.9 .002 2.312
r =6 77272 77311.8 .020 2.332
p=1-exp(-SUM/2)= .68840
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 14 to 21
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 925 944.3 .395 .395
r =5 21587 21743.9 1.132 1.527
r =6 77488 77311.8 .402 1.928
p=1-exp(-SUM/2)= .61868
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 15 to 22
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 952 944.3 .063 .063
r =5 21676 21743.9 .212 .275
r =6 77372 77311.8 .047 .322
p=1-exp(-SUM/2)= .14857
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 16 to 23
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 922 944.3 .527 .527
r =5 21695 21743.9 .110 .637
r =6 77383 77311.8 .066 .702
p=1-exp(-SUM/2)= .29609
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 17 to 24
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 973 944.3 .872 .872
r =5 21672 21743.9 .238 1.110
r =6 77355 77311.8 .024 1.134
p=1-exp(-SUM/2)= .43280
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 18 to 25
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 931 944.3 .187 .187
r =5 21652 21743.9 .388 .576
r =6 77417 77311.8 .143 .719
p=1-exp(-SUM/2)= .30194
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 19 to 26
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 925 944.3 .395 .395
r =5 22003 21743.9 3.087 3.482
r =6 77072 77311.8 .744 4.226
p=1-exp(-SUM/2)= .87911
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 20 to 27
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 930 944.3 .217 .217
r =5 21869 21743.9 .720 .936
r =6 77201 77311.8 .159 1.095
p=1-exp(-SUM/2)= .42165
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 21 to 28
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 952 944.3 .063 .063
r =5 21993 21743.9 2.854 2.916
r =6 77055 77311.8 .853 3.769
p=1-exp(-SUM/2)= .84813
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 22 to 29
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 901 944.3 1.986 1.986
r =5 21895 21743.9 1.050 3.036
r =6 77204 77311.8 .150 3.186
p=1-exp(-SUM/2)= .79668
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 23 to 30
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 917 944.3 .789 .789
r =5 21803 21743.9 .161 .950
r =6 77280 77311.8 .013 .963
p=1-exp(-SUM/2)= .38216
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 24 to 31
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 947 944.3 .008 .008
r =5 21884 21743.9 .903 .910
r =6 77169 77311.8 .264 1.174
p=1-exp(-SUM/2)= .44406
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 25 to 32
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 922 944.3 .527 .527
r =5 21887 21743.9 .942 1.468
r =6 77191 77311.8 .189 1.657
p=1-exp(-SUM/2)= .56334
TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices
These should be 25 uniform [0,1] random variables:
.431707 .484585 .207916 .289616 .122664
.916950 .276729 .365746 .076665 .313130
.057625 .781832 .688402 .618680 .148567
.296093 .432799 .301944 .879111 .421645
.848132 .796677 .382156 .444056 .563341
brank test summary for RANDOM.DAT
The KS test for those 25 supposed UNI's yields
KS p-value= .610572
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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: 142006 missing words, .23 sigmas from mean, p-value= .58935
tst no 2: 141653 missing words, -.60 sigmas from mean, p-value= .27462
tst no 3: 142202 missing words, .68 sigmas from mean, p-value= .75295
tst no 4: 142030 missing words, .28 sigmas from mean, p-value= .61101
tst no 5: 141844 missing words, -.15 sigmas from mean, p-value= .43934
tst no 6: 142144 missing words, .55 sigmas from mean, p-value= .70826
tst no 7: 141572 missing words, -.79 sigmas from mean, p-value= .21530
tst no 8: 141954 missing words, .10 sigmas from mean, p-value= .54156
tst no 9: 142098 missing words, .44 sigmas from mean, p-value= .67033
tst no 10: 142575 missing words, 1.56 sigmas from mean, p-value= .94006
tst no 11: 141601 missing words, -.72 sigmas from mean, p-value= .23564
tst no 12: 142067 missing words, .37 sigmas from mean, p-value= .64371
tst no 13: 141983 missing words, .17 sigmas from mean, p-value= .56833
tst no 14: 141504 missing words, -.95 sigmas from mean, p-value= .17181
tst no 15: 141438 missing words, -1.10 sigmas from mean, p-value= .13540
tst no 16: 141594 missing words, -.74 sigmas from mean, p-value= .23064
tst no 17: 141745 missing words, -.38 sigmas from mean, p-value= .35051
tst no 18: 141544 missing words, -.85 sigmas from mean, p-value= .19667
tst no 19: 141771 missing words, -.32 sigmas from mean, p-value= .37327
tst no 20: 142689 missing words, 1.82 sigmas from mean, p-value= .96575
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
Output: No. missing words (mw), equiv normal variate (z), p-value (p)
mw z p
OPSO for RANDOM.DAT using bits 23 to 32 142353 1.530 .9370
OPSO for RANDOM.DAT using bits 22 to 31 141948 .133 .5530
OPSO for RANDOM.DAT using bits 21 to 30 141359 -1.898 .0289
OPSO for RANDOM.DAT using bits 20 to 29 141952 .147 .5585
OPSO for RANDOM.DAT using bits 19 to 28 141574 -1.156 .1238
OPSO for RANDOM.DAT using bits 18 to 27 141708 -.694 .2438
OPSO for RANDOM.DAT using bits 17 to 26 141989 .275 .6082
OPSO for RANDOM.DAT using bits 16 to 25 141829 -.277 .3909
OPSO for RANDOM.DAT using bits 15 to 24 142060 .520 .6983
OPSO for RANDOM.DAT using bits 14 to 23 142452 1.871 .9693
OPSO for RANDOM.DAT using bits 13 to 22 141985 .261 .6029
OPSO for RANDOM.DAT using bits 12 to 21 141683 -.780 .2176
OPSO for RANDOM.DAT using bits 11 to 20 141499 -1.415 .0785
OPSO for RANDOM.DAT using bits 10 to 19 141770 -.480 .3155
OPSO for RANDOM.DAT using bits 9 to 18 142478 1.961 .9751
OPSO for RANDOM.DAT using bits 8 to 17 142486 1.989 .9766
OPSO for RANDOM.DAT using bits 7 to 16 141857 -.180 .4284
OPSO for RANDOM.DAT using bits 6 to 15 141427 -1.663 .0481
OPSO for RANDOM.DAT using bits 5 to 14 142004 .326 .6280
OPSO for RANDOM.DAT using bits 4 to 13 141936 .092 .5366
OPSO for RANDOM.DAT using bits 3 to 12 141720 -.653 .2569
OPSO for RANDOM.DAT using bits 2 to 11 141737 -.594 .2762
OPSO for RANDOM.DAT using bits 1 to 10 141786 -.425 .3353
OQSO test for generator RANDOM.DAT
Output: No. missing words (mw), equiv normal variate (z), p-value (p)
mw z p
OQSO for RANDOM.DAT using bits 28 to 32 141803 -.360 .3593
OQSO for RANDOM.DAT using bits 27 to 31 142025 .392 .6525
OQSO for RANDOM.DAT using bits 26 to 30 142139 .779 .7819
OQSO for RANDOM.DAT using bits 25 to 29 141758 -.513 .3040
OQSO for RANDOM.DAT using bits 24 to 28 141477 -1.466 .0714
OQSO for RANDOM.DAT using bits 23 to 27 142028 .402 .6563
OQSO for RANDOM.DAT using bits 22 to 26 141830 -.269 .3940
OQSO for RANDOM.DAT using bits 21 to 25 142098 .640 .7388
OQSO for RANDOM.DAT using bits 20 to 24 141608 -1.021 .1535
OQSO for RANDOM.DAT using bits 19 to 23 141877 -.110 .4564
OQSO for RANDOM.DAT using bits 18 to 22 142625 2.426 .9924
OQSO for RANDOM.DAT using bits 17 to 21 141716 -.655 .2561
OQSO for RANDOM.DAT using bits 16 to 20 141698 -.716 .2369
OQSO for RANDOM.DAT using bits 15 to 19 141835 -.252 .4005
OQSO for RANDOM.DAT using bits 14 to 18 142062 .518 .6976
OQSO for RANDOM.DAT using bits 13 to 17 142346 1.480 .9306
OQSO for RANDOM.DAT using bits 12 to 16 142301 1.328 .9079
OQSO for RANDOM.DAT using bits 11 to 15 141761 -.503 .3075
OQSO for RANDOM.DAT using bits 10 to 14 142438 1.792 .9634
OQSO for RANDOM.DAT using bits 9 to 13 141924 .050 .5198
OQSO for RANDOM.DAT using bits 8 to 12 141234 -2.289 .0110
OQSO for RANDOM.DAT using bits 7 to 11 141910 .002 .5009
OQSO for RANDOM.DAT using bits 6 to 10 141864 -.154 .4389
OQSO for RANDOM.DAT using bits 5 to 9 141973 .216 .5854
OQSO for RANDOM.DAT using bits 4 to 8 141923 .046 .5185
OQSO for RANDOM.DAT using bits 3 to 7 141481 -1.452 .0733
OQSO for RANDOM.DAT using bits 2 to 6 141798 -.377 .3529
OQSO for RANDOM.DAT using bits 1 to 5 141897 -.042 .4833
DNA test for generator RANDOM.DAT
Output: No. missing words (mw), equiv normal variate (z), p-value (p)
mw z p
DNA for RANDOM.DAT using bits 31 to 32 141440 -1.384 .0831
DNA for RANDOM.DAT using bits 30 to 31 141983 .217 .5860
DNA for RANDOM.DAT using bits 29 to 30 142227 .937 .8256
DNA for RANDOM.DAT using bits 28 to 29 141438 -1.390 .0822
DNA for RANDOM.DAT using bits 27 to 28 141153 -2.231 .0128
DNA for RANDOM.DAT using bits 26 to 27 142479 1.680 .9536
DNA for RANDOM.DAT using bits 25 to 26 141691 -.644 .2598
DNA for RANDOM.DAT using bits 24 to 25 142340 1.270 .8980
DNA for RANDOM.DAT using bits 23 to 24 141246 -1.957 .0252
DNA for RANDOM.DAT using bits 22 to 23 141262 -1.910 .0281
DNA for RANDOM.DAT using bits 21 to 22 142179 .795 .7868
DNA for RANDOM.DAT using bits 20 to 21 140875 -3.051 .0011
DNA for RANDOM.DAT using bits 19 to 20 141821 -.261 .3972
DNA for RANDOM.DAT using bits 18 to 19 141599 -.915 .1800
DNA for RANDOM.DAT using bits 17 to 18 143063 3.403 .9997
DNA for RANDOM.DAT using bits 16 to 17 142477 1.675 .9530
DNA for RANDOM.DAT using bits 15 to 16 141627 -.833 .2025
DNA for RANDOM.DAT using bits 14 to 15 141751 -.467 .3202
DNA for RANDOM.DAT using bits 13 to 14 141737 -.508 .3056
DNA for RANDOM.DAT using bits 12 to 13 142065 .459 .6770
DNA for RANDOM.DAT using bits 11 to 12 141656 -.747 .2274
DNA for RANDOM.DAT using bits 10 to 11 141638 -.800 .2117
DNA for RANDOM.DAT using bits 9 to 10 141590 -.942 .1731
DNA for RANDOM.DAT using bits 8 to 9 141788 -.358 .3602
DNA for RANDOM.DAT using bits 7 to 8 141491 -1.234 .1086
DNA for RANDOM.DAT using bits 6 to 7 141271 -1.883 .0299
DNA for RANDOM.DAT using bits 5 to 6 141837 -.213 .4155
DNA for RANDOM.DAT using bits 4 to 5 141648 -.771 .2204
DNA for RANDOM.DAT using bits 3 to 4 142162 .745 .7720
DNA for RANDOM.DAT using bits 2 to 3 141776 -.393 .3470
DNA for RANDOM.DAT using bits 1 to 2 141928 .055 .5220
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
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 RANDOM.DAT 2414.83 -1.205 .114198
byte stream for RANDOM.DAT 2461.03 -.551 .290760
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 2593.13 1.317 .906078
bits 2 to 9 2444.86 -.780 .217767
bits 3 to 10 2456.36 -.617 .268566
bits 4 to 11 2525.77 .364 .642228
bits 5 to 12 2510.96 .155 .561603
bits 6 to 13 2421.20 -1.114 .132544
bits 7 to 14 2388.79 -1.573 .057893
bits 8 to 15 2525.51 .361 .640882
bits 9 to 16 2524.32 .344 .634563
bits 10 to 17 2533.04 .467 .679847
bits 11 to 18 2471.87 -.398 .345388
bits 12 to 19 2484.95 -.213 .415749
bits 13 to 20 2605.33 1.490 .931825
bits 14 to 21 2527.99 .396 .653887
bits 15 to 22 2447.65 -.740 .229543
bits 16 to 23 2482.62 -.246 .402910
bits 17 to 24 2477.67 -.316 .376055
bits 18 to 25 2501.71 .024 .509664
bits 19 to 26 2491.46 -.121 .451938
bits 20 to 27 2460.94 -.552 .290343
bits 21 to 28 2534.19 .483 .685616
bits 22 to 29 2463.83 -.512 .304493
bits 23 to 30 2471.00 -.410 .340849
bits 24 to 31 2522.05 .312 .622398
bits 25 to 32 2492.93 -.100 .460151
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
Of 12,000 tries, the average no. of successes
should be 3523 with sigma=21.9
Successes: 3512 z-score: -.502 p-value: .307734
Successes: 3533 z-score: .457 p-value: .676028
Successes: 3507 z-score: -.731 p-value: .232514
Successes: 3504 z-score: -.868 p-value: .192812
Successes: 3507 z-score: -.731 p-value: .232514
Successes: 3523 z-score: .000 p-value: .500000
Successes: 3569 z-score: 2.100 p-value: .982156
Successes: 3547 z-score: 1.096 p-value: .863437
Successes: 3525 z-score: .091 p-value: .536382
Successes: 3564 z-score: 1.872 p-value: .969407
square size avg. no. parked sample sigma
100. 3529.100 22.565
KSTEST for the above 10: p= .442307
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
Sample no. d^2 avg equiv uni
5 .6879 .7557 .499098
10 .3424 .9733 .291163
15 .8746 .8918 .584817
20 1.0775 .8223 .661398
25 .2010 .8786 .182884
30 1.5725 .8188 .794105
35 .4604 .7938 .370454
40 1.3411 .8860 .740201
45 1.1714 .9274 .691874
50 .9768 1.0376 .625330
55 2.3302 1.1016 .903856
60 .4418 1.0587 .358542
65 3.2638 1.0556 .962379
70 .3543 1.0440 .299559
75 .5456 1.0239 .422082
80 .0511 .9845 .050064
85 .3677 .9887 .308948
90 1.2586 .9631 .717744
95 .1363 .9543 .128034
100 1.7100 .9480 .820678
MINIMUM DISTANCE TEST for RANDOM.DAT
Result of KS test on 20 transformed mindist^2's:
p-value= .651329
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
sample no: 1 r^3= 18.139 p-value= .45372
sample no: 2 r^3= 7.267 p-value= .21514
sample no: 3 r^3= 29.283 p-value= .62322
sample no: 4 r^3= 4.889 p-value= .15037
sample no: 5 r^3= 40.659 p-value= .74213
sample no: 6 r^3= 85.962 p-value= .94304
sample no: 7 r^3= 11.160 p-value= .31064
sample no: 8 r^3= 59.258 p-value= .86127
sample no: 9 r^3= 66.360 p-value= .89052
sample no: 10 r^3= 43.366 p-value= .76438
sample no: 11 r^3= 9.566 p-value= .27303
sample no: 12 r^3= 65.531 p-value= .88745
sample no: 13 r^3= 40.858 p-value= .74383
sample no: 14 r^3= 23.785 p-value= .54744
sample no: 15 r^3= 40.013 p-value= .73651
sample no: 16 r^3= 20.736 p-value= .49903
sample no: 17 r^3= 115.710 p-value= .97887
sample no: 18 r^3= 4.672 p-value= .14423
sample no: 19 r^3= 69.854 p-value= .90256
sample no: 20 r^3= 12.950 p-value= .35057
A KS test is applied to those 20 p-values.
---------------------------------------------------------
3DSPHERES test for file RANDOM.DAT p-value= .808836
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
Table of standardized frequency counts
( (obs-exp)/sqrt(exp) )^2
for j taking values <=6,7,8,...,47,>=48:
-.8 .5 -.6 -1.1 -.9 -.8
.9 -.2 -1.5 -.6 -.3 .5
.8 -.2 .4 .4 1.3 .0
.3 -.3 -.6 .3 .5 -1.3
.0 .6 -1.4 -2.4 .8 .6
.8 .7 -1.7 .5 -.8 .2
.5 -1.3 -.8 -.1 -.6 .0
-.1
Chi-square with 42 degrees of freedom: 30.167
z-score= -1.291 p-value= .086423
______________________________________________________________
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 .603623
Test no. 2 p-value .439628
Test no. 3 p-value .343840
Test no. 4 p-value .406551
Test no. 5 p-value .076443
Test no. 6 p-value .284891
Test no. 7 p-value .035207
Test no. 8 p-value .122706
Test no. 9 p-value .253004
Test no. 10 p-value .985781
Results of the OSUM test for RANDOM.DAT
KSTEST on the above 10 p-values: .844669
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
Up and down runs in a sample of 10000
_________________________________________________
Run test for RANDOM.DAT :
runs up; ks test for 10 p's: .171462
runs down; ks test for 10 p's: .515727
Run test for RANDOM.DAT :
runs up; ks test for 10 p's: .748610
runs down; ks test for 10 p's: .588038
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
No. of wins: Observed Expected
98442 98585.86
98442= No. of wins, z-score= -.643 pvalue= .25997
Analysis of Throws-per-Game:
Chisq= 14.76 for 20 degrees of freedom, p= .21012
Throws Observed Expected Chisq Sum
1 66588 66666.7 .093 .093
2 37538 37654.3 .359 .452
3 26984 26954.7 .032 .484
4 19418 19313.5 .566 1.050
5 13747 13851.4 .787 1.837
6 9918 9943.5 .066 1.903
7 7148 7145.0 .001 1.904
8 5206 5139.1 .872 2.775
9 3741 3699.9 .457 3.233
10 2774 2666.3 4.351 7.583
11 1933 1923.3 .049 7.632
12 1361 1388.7 .554 8.186
13 1045 1003.7 1.698 9.884
14 700 726.1 .941 10.825
15 541 525.8 .437 11.263
16 354 381.2 1.934 13.197
17 271 276.5 .111 13.308
18 190 200.8 .584 13.892
19 156 146.0 .687 14.579
20 102 106.2 .167 14.746
21 285 287.1 .016 14.762
SUMMARY FOR RANDOM.DAT
p-value for no. of wins: .259975
p-value for throws/game: .210121
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Results of DIEHARD battery of tests sent to file RESULTS.TXT
|
FOR COMPARISON PURPOSES,
WE USED THE rand() FUNCTION IN VISUAL C++ 6
TO GENERATE A 12.5 MB FILE OF TEST DATA. WE PERFORMED THE SAME TESTS AS
ON THE FILE GENERATED BY REALLY RANDOM NUMBERS. NOTICE THE DIFFERENCES:
* The C++ generated file fails the chi-square test badly with
ENT.EXE
* The C++ generated file generates extreme p-values 0 or 1 often with
DIEHARD.EXE
CONCLUSION? C++ DOES NOT GENERATE REALLY RANDOM NUMBERS.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: TEST RESULTS FROM ENT.EXE ::
:: http://www.fourmilab.ch/random/ ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Entropy = 7.999997 bits per byte.
Optimum compression would reduce the size
of this 12750000 byte file by 0 percent.
Chi square distribution for 12750000 samples is 59.25, and
randomly
would exceed this value 99.99 percent of the times.
Arithmetic mean value of data bytes is 127.5046 (127.5 = random).
Monte Carlo value for Pi is 3.140747294 (error 0.03 percent).
Serial correlation coefficient is 0.000092 (totally uncorrelated = 0.0).
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: TEST RESULTS FROM DIEHARD.EXE ::
:: http://stat.fsu.edu/~geo/diehard.html ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
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 RANDOM.DAT
For a sample of size 500: mean
RANDOM.DAT using bits 1 to 24 6.574
duplicate number number
spacings observed expected
0 0. 67.668
1 3. 135.335
2 11. 135.335
3 37. 90.224
4 49. 45.112
5 81. 18.045
6 to INF 319. 8.282
Chisquare with 6 d.o.f. = 12220.25 p-value= 1.000000
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 2 to 25 5.686
duplicate number number
spacings observed expected
0 1. 67.668
1 10. 135.335
2 39. 135.335
3 47. 90.224
4 73. 45.112
5 87. 18.045
6 to INF 243. 8.282
Chisquare with 6 d.o.f. = 7204.03 p-value= 1.000000
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 3 to 26 5.470
duplicate number number
spacings observed expected
0 0. 67.668
1 7. 135.335
2 35. 135.335
3 64. 90.224
4 77. 45.112
5 82. 18.045
6 to INF 235. 8.282
Chisquare with 6 d.o.f. = 6727.10 p-value= 1.000000
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 4 to 27 2.532
duplicate number number
spacings observed expected
0 31. 67.668
1 115. 135.335
2 126. 135.335
3 93. 90.224
4 85. 45.112
5 31. 18.045
6 to INF 19. 8.282
Chisquare with 6 d.o.f. = 82.10 p-value= 1.000000
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 5 to 28 2.084
duplicate number number
spacings observed expected
0 57. 67.668
1 132. 135.335
2 139. 135.335
3 91. 90.224
4 53. 45.112
5 22. 18.045
6 to INF 6. 8.282
Chisquare with 6 d.o.f. = 4.74 p-value= .423070
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 6 to 29 2.286
duplicate number number
spacings observed expected
0 32. 67.668
1 129. 135.335
2 141. 135.335
3 98. 90.224
4 71. 45.112
5 20. 18.045
6 to INF 9. 8.282
Chisquare with 6 d.o.f. = 35.13 p-value= .999996
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 7 to 30 2.568
duplicate number number
spacings observed expected
0 43. 67.668
1 94. 135.335
2 131. 135.335
3 85. 90.224
4 88. 45.112
5 39. 18.045
6 to INF 20. 8.282
Chisquare with 6 d.o.f. = 103.75 p-value= 1.000000
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 8 to 31 5.028
duplicate number number
spacings observed expected
0 3. 67.668
1 20. 135.335
2 43. 135.335
3 62. 90.224
4 102. 45.112
5 79. 18.045
6 to INF 191. 8.282
Chisquare with 6 d.o.f. = 4540.80 p-value= 1.000000
:::::::::::::::::::::::::::::::::::::::::
For a sample of size 500: mean
RANDOM.DAT using bits 9 to 32 6.682
duplicate number number
spacings observed expected
0 1. 67.668
1 6. 135.335
2 11. 135.335
3 33. 90.224
4 51. 45.112
5 74. 18.045
6 to INF 324. 8.282
Chisquare with 6 d.o.f. = 12549.86 p-value= 1.000000
:::::::::::::::::::::::::::::::::::::::::
The 9 p-values were
1.000000 1.000000 1.000000 1.000000 .423070
.999996 1.000000 1.000000 1.000000
A KSTEST for the 9 p-values yields 1.000000
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
For a sample of 1,000,000 consecutive 5-tuples,
chisquare for 99 degrees of freedom= 48.942; p-value= .000006
OPERM5 test for file RANDOM.DAT
For a sample of 1,000,000 consecutive 5-tuples,
chisquare for 99 degrees of freedom= 44.644; p-value= .000001
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
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 202 211.4 .419543 .420
29 5137 5134.0 .001741 .421
30 23230 23103.0 .697618 1.119
31 11431 11551.5 1.257508 2.376
chisquare= 2.376 for 3 d. of f.; p-value= .563550
--------------------------------------------------------------
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
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 223 211.4 .634489 .634
30 5107 5134.0 .142102 .777
31 23148 23103.0 .087468 .864
32 11522 11551.5 .075461 .940
chisquare= .940 for 3 d. of f.; p-value= .350319
--------------------------------------------------------------
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 1 to 8
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 916 944.3 .848 .848
r =5 21782 21743.9 .067 .915
r =6 77302 77311.8 .001 .916
p=1-exp(-SUM/2)= .36752
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 2 to 9
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 958 944.3 .199 .199
r =5 21677 21743.9 .206 .405
r =6 77365 77311.8 .037 .441
p=1-exp(-SUM/2)= .19795
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 3 to 10
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 965 944.3 .454 .454
r =5 21813 21743.9 .220 .673
r =6 77222 77311.8 .104 .778
p=1-exp(-SUM/2)= .32214
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 4 to 11
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 875 944.3 5.086 5.086
r =5 21933 21743.9 1.645 6.730
r =6 77192 77311.8 .186 6.916
p=1-exp(-SUM/2)= .96851
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 5 to 12
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 906 944.3 1.554 1.554
r =5 21830 21743.9 .341 1.894
r =6 77264 77311.8 .030 1.924
p=1-exp(-SUM/2)= .61787
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 6 to 13
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 980 944.3 1.350 1.350
r =5 21821 21743.9 .273 1.623
r =6 77199 77311.8 .165 1.788
p=1-exp(-SUM/2)= .59089
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 7 to 14
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 982 944.3 1.505 1.505
r =5 21704 21743.9 .073 1.578
r =6 77314 77311.8 .000 1.578
p=1-exp(-SUM/2)= .54577
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 8 to 15
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 948 944.3 .014 .014
r =5 21757 21743.9 .008 .022
r =6 77295 77311.8 .004 .026
p=1-exp(-SUM/2)= .01293
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 9 to 16
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 1001 944.3 3.404 3.404
r =5 21548 21743.9 1.765 5.169
r =6 77451 77311.8 .251 5.420
p=1-exp(-SUM/2)= .93346
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 10 to 17
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 919 944.3 .678 .678
r =5 21588 21743.9 1.118 1.796
r =6 77493 77311.8 .425 2.220
p=1-exp(-SUM/2)= .67050
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 11 to 18
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 940 944.3 .020 .020
r =5 21693 21743.9 .119 .139
r =6 77367 77311.8 .039 .178
p=1-exp(-SUM/2)= .08522
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 12 to 19
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 912 944.3 1.105 1.105
r =5 21533 21743.9 2.046 3.150
r =6 77555 77311.8 .765 3.916
p=1-exp(-SUM/2)= .85882
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 13 to 20
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 922 944.3 .527 .527
r =5 21818 21743.9 .253 .779
r =6 77260 77311.8 .035 .814
p=1-exp(-SUM/2)= .33433
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 14 to 21
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 984 944.3 1.669 1.669
r =5 21690 21743.9 .134 1.803
r =6 77326 77311.8 .003 1.805
p=1-exp(-SUM/2)= .59448
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 15 to 22
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 1017 944.3 5.597 5.597
r =5 21663 21743.9 .301 5.898
r =6 77320 77311.8 .001 5.899
p=1-exp(-SUM/2)= .94763
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 16 to 23
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 954 944.3 .100 .100
r =5 21877 21743.9 .815 .914
r =6 77169 77311.8 .264 1.178
p=1-exp(-SUM/2)= .44515
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 17 to 24
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 996 944.3 2.830 2.830
r =5 21826 21743.9 .310 3.140
r =6 77178 77311.8 .232 3.372
p=1-exp(-SUM/2)= .81474
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 18 to 25
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 924 944.3 .436 .436
r =5 21840 21743.9 .425 .861
r =6 77236 77311.8 .074 .936
p=1-exp(-SUM/2)= .37359
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 19 to 26
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 925 944.3 .395 .395
r =5 21755 21743.9 .006 .400
r =6 77320 77311.8 .001 .401
p=1-exp(-SUM/2)= .18170
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 20 to 27
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 949 944.3 .023 .023
r =5 21693 21743.9 .119 .143
r =6 77358 77311.8 .028 .170
p=1-exp(-SUM/2)= .08155
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 21 to 28
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 929 944.3 .248 .248
r =5 21775 21743.9 .044 .292
r =6 77296 77311.8 .003 .296
p=1-exp(-SUM/2)= .13742
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 22 to 29
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 1009 944.3 4.433 4.433
r =5 21561 21743.9 1.538 5.971
r =6 77430 77311.8 .181 6.152
p=1-exp(-SUM/2)= .95386
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 23 to 30
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 963 944.3 .370 .370
r =5 21741 21743.9 .000 .371
r =6 77296 77311.8 .003 .374
p=1-exp(-SUM/2)= .17051
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 24 to 31
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 988 944.3 2.022 2.022
r =5 21542 21743.9 1.875 3.897
r =6 77470 77311.8 .324 4.221
p=1-exp(-SUM/2)= .87880
Rank of a 6x8 binary matrix,
rows formed from eight bits of the RNG RANDOM.DAT
b-rank test for bits 25 to 32
OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 926 944.3 .355 .355
r =5 21578 21743.9 1.266 1.620
r =6 77496 77311.8 .439 2.059
p=1-exp(-SUM/2)= .64287
TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices
These should be 25 uniform [0,1] random variables:
.367518 .197947 .322135 .968509 .617873
.590890 .545770 .012932 .933461 .670501
.085223 .858825 .334327 .594479 .947627
.445153 .814739 .373590 .181698 .081550
.137418 .953857 .170508 .878801 .642871
brank test summary for RANDOM.DAT
The KS test for those 25 supposed UNI's yields
KS p-value= .095433
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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: 142665 missing words, 1.77 sigmas from mean, p-value= .96127
tst no 2: 143178 missing words, 2.96 sigmas from mean, p-value= .99848
tst no 3: 142630 missing words, 1.68 sigmas from mean, p-value= .95389
tst no 4: 142420 missing words, 1.19 sigmas from mean, p-value= .88360
tst no 5: 143280 missing words, 3.20 sigmas from mean, p-value= .99932
tst no 6: 142999 missing words, 2.55 sigmas from mean, p-value= .99455
tst no 7: 142635 missing words, 1.70 sigmas from mean, p-value= .95501
tst no 8: 142651 missing words, 1.73 sigmas from mean, p-value= .95844
tst no 9: 142757 missing words, 1.98 sigmas from mean, p-value= .97618
tst no 10: 142842 missing words, 2.18 sigmas from mean, p-value= .98534
tst no 11: 142148 missing words, .56 sigmas from mean, p-value= .71146
tst no 12: 142588 missing words, 1.59 sigmas from mean, p-value= .94359
tst no 13: 142844 missing words, 2.18 sigmas from mean, p-value= .98551
tst no 14: 142798 missing words, 2.08 sigmas from mean, p-value= .98107
tst no 15: 142608 missing words, 1.63 sigmas from mean, p-value= .94870
tst no 16: 142358 missing words, 1.05 sigmas from mean, p-value= .85275
tst no 17: 143085 missing words, 2.75 sigmas from mean, p-value= .99699
tst no 18: 142985 missing words, 2.51 sigmas from mean, p-value= .99402
tst no 19: 143131 missing words, 2.85 sigmas from mean, p-value= .99784
tst no 20: 142854 missing words, 2.21 sigmas from mean, p-value= .98635
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
Output: No. missing words (mw), equiv normal variate (z), p-value (p)
mw z p
OPSO for RANDOM.DAT using bits 23 to 32 85186******* .0000
OPSO for RANDOM.DAT using bits 22 to 31 84244******* .0000
OPSO for RANDOM.DAT using bits 21 to 30 81032******* .0000
OPSO for RANDOM.DAT using bits 20 to 29 89058******* .0000
OPSO for RANDOM.DAT using bits 19 to 28 118236-81.632 .0000
OPSO for RANDOM.DAT using bits 18 to 27 96336******* .0000
OPSO for RANDOM.DAT using bits 17 to 26 79380******* .0000
OPSO for RANDOM.DAT using bits 16 to 25 102845******* .0000
OPSO for RANDOM.DAT using bits 15 to 24 85710******* .0000
OPSO for RANDOM.DAT using bits 14 to 23 84221******* .0000
OPSO for RANDOM.DAT using bits 13 to 22 80847******* .0000
OPSO for RANDOM.DAT using bits 12 to 21 89336******* .0000
OPSO for RANDOM.DAT using bits 11 to 20 118132-81.991 .0000
OPSO for RANDOM.DAT using bits 10 to 19 95353******* .0000
OPSO for RANDOM.DAT using bits 9 to 18 79485******* .0000
OPSO for RANDOM.DAT using bits 8 to 17 102316******* .0000
OPSO for RANDOM.DAT using bits 7 to 16 85111******* .0000
OPSO for RANDOM.DAT using bits 6 to 15 84237******* .0000
OPSO for RANDOM.DAT using bits 5 to 14 80612******* .0000
OPSO for RANDOM.DAT using bits 4 to 13 89510******* .0000
OPSO for RANDOM.DAT using bits 3 to 12 117776-83.218 .0000
OPSO for RANDOM.DAT using bits 2 to 11 95801******* .0000
OPSO for RANDOM.DAT using bits 1 to 10 79455******* .0000
OQSO test for generator RANDOM.DAT
Output: No. missing words (mw), equiv normal variate (z), p-value (p)
mw z p
OQSO for RANDOM.DAT using bits 28 to 32 641472******* 1.0000
OQSO for RANDOM.DAT using bits 27 to 31 333376649.040 1.0000
OQSO for RANDOM.DAT using bits 26 to 30 60384******* .0000
OQSO for RANDOM.DAT using bits 25 to 29 103500******* .0000
OQSO for RANDOM.DAT using bits 24 to 28 134083-26.530 .0000
OQSO for RANDOM.DAT using bits 23 to 27 206030217.358 1.0000
OQSO for RANDOM.DAT using bits 22 to 26 147342 18.416 1.0000
OQSO for RANDOM.DAT using bits 21 to 25 321087607.382 1.0000
OQSO for RANDOM.DAT using bits 20 to 24 641248******* 1.0000
OQSO for RANDOM.DAT using bits 19 to 23 333472649.365 1.0000
OQSO for RANDOM.DAT using bits 18 to 22 61056******* .0000
OQSO for RANDOM.DAT using bits 17 to 21 103567******* .0000
OQSO for RANDOM.DAT using bits 16 to 20 126117-53.533 .0000
OQSO for RANDOM.DAT using bits 15 to 19 209170228.002 1.0000
OQSO for RANDOM.DAT using bits 14 to 18 187714155.270 1.0000
OQSO for RANDOM.DAT using bits 13 to 17 359471737.497 1.0000
OQSO for RANDOM.DAT using bits 12 to 16 641408******* 1.0000
OQSO for RANDOM.DAT using bits 11 to 15 333568649.690 1.0000
OQSO for RANDOM.DAT using bits 10 to 14 61216******* .0000
OQSO for RANDOM.DAT using bits 9 to 13 102816******* .0000
OQSO for RANDOM.DAT using bits 8 to 12 134310-25.760 .0000
OQSO for RANDOM.DAT using bits 7 to 11 211559236.101 1.0000
OQSO for RANDOM.DAT using bits 6 to 10 222853274.385 1.0000
OQSO for RANDOM.DAT using bits 5 to 9 424544958.084 1.0000
OQSO for RANDOM.DAT using bits 4 to 8 640960******* 1.0000
OQSO for RANDOM.DAT using bits 3 to 7 334016651.209 1.0000
OQSO for RANDOM.DAT using bits 2 to 6 60640******* .0000
OQSO for RANDOM.DAT using bits 1 to 5 103611******* .0000
DNA test for generator RANDOM.DAT
Output: No. missing words (mw), equiv normal variate (z), p-value (p)
mw z p
DNA for RANDOM.DAT using bits 31 to 32 988364******* 1.0000
DNA for RANDOM.DAT using bits 30 to 31 934892******* 1.0000
DNA for RANDOM.DAT using bits 29 to 30 840284******* 1.0000
DNA for RANDOM.DAT using bits 28 to 29 650172******* 1.0000
DNA for RANDOM.DAT using bits 27 to 28 454452921.955 1.0000
DNA for RANDOM.DAT using bits 26 to 27 257852342.014 1.0000
DNA for RANDOM.DAT using bits 25 to 26 254529332.211 1.0000
DNA for RANDOM.DAT using bits 24 to 25 165710 70.208 1.0000
DNA for RANDOM.DAT using bits 23 to 24 988292******* 1.0000
DNA for RANDOM.DAT using bits 22 to 23 934816******* 1.0000
DNA for RANDOM.DAT using bits 21 to 22 839084******* 1.0000
DNA for RANDOM.DAT using bits 20 to 21 651672******* 1.0000
DNA for RANDOM.DAT using bits 19 to 20 454172921.129 1.0000
DNA for RANDOM.DAT using bits 18 to 19 257644341.400 1.0000
DNA for RANDOM.DAT using bits 17 to 18 257670341.477 1.0000
DNA for RANDOM.DAT using bits 16 to 17 208689196.990 1.0000
DNA for RANDOM.DAT using bits 15 to 16 988656******* 1.0000
DNA for RANDOM.DAT using bits 14 to 15 934788******* 1.0000
DNA for RANDOM.DAT using bits 13 to 14 839016******* 1.0000
DNA for RANDOM.DAT using bits 12 to 13 650120******* 1.0000
DNA for RANDOM.DAT using bits 11 to 12 454120920.975 1.0000
DNA for RANDOM.DAT using bits 10 to 11 257560341.152 1.0000
DNA for RANDOM.DAT using bits 9 to 10 259593347.149 1.0000
DNA for RANDOM.DAT using bits 8 to 9 225272245.908 1.0000
DNA for RANDOM.DAT using bits 7 to 8 988228******* 1.0000
DNA for RANDOM.DAT using bits 6 to 7 934768******* 1.0000
DNA for RANDOM.DAT using bits 5 to 6 839208******* 1.0000
DNA for RANDOM.DAT using bits 4 to 5 651560******* 1.0000
DNA for RANDOM.DAT using bits 3 to 4 453760919.914 1.0000
DNA for RANDOM.DAT using bits 2 to 3 257824341.931 1.0000
DNA for RANDOM.DAT using bits 1 to 2 255914336.297 1.0000
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
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 RANDOM.DAT 2479.78 -.286 .387483
byte stream for RANDOM.DAT 2562.09 .878 .810056
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 2446.26 -.760 .223610
bits 2 to 9 2418.35 -1.155 .124099
bits 3 to 10 2545.54 .644 .740214
bits 4 to 11 2529.78 .421 .663165
bits 5 to 12 2566.01 .933 .824717
bits 6 to 13 2460.36 -.561 .287538
bits 7 to 14 2495.92 -.058 .476978
bits 8 to 15 2536.53 .517 .697274
bits 9 to 16 2506.22 .088 .535021
bits 10 to 17 2465.68 -.485 .313735
bits 11 to 18 2488.06 -.169 .432934
bits 12 to 19 2484.02 -.226 .410601
bits 13 to 20 2566.01 .934 .824721
bits 14 to 21 2592.61 1.310 .904857
bits 15 to 22 2593.77 1.326 .907589
bits 16 to 23 2402.07 -1.385 .083035
bits 17 to 24 2417.84 -1.162 .122625
bits 18 to 25 2501.43 .020 .508080
bits 19 to 26 2438.04 -.876 .190454
bits 20 to 27 2391.54 -1.534 .062528
bits 21 to 28 2363.70 -1.928 .026952
bits 22 to 29 2444.48 -.785 .216190
bits 23 to 30 2512.49 .177 .570130
bits 24 to 31 2546.05 .651 .742543
bits 25 to 32 2519.22 .272 .607093
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
Of 12,000 tries, the average no. of successes
should be 3523 with sigma=21.9
Successes: 3491 z-score: -1.461 p-value: .071982
Successes: 3468 z-score: -2.511 p-value: .006012
Successes: 3499 z-score: -1.096 p-value: .136563
Successes: 3486 z-score: -1.689 p-value: .045562
Successes: 3483 z-score: -1.826 p-value: .033889
Successes: 3502 z-score: -.959 p-value: .168804
Successes: 3501 z-score: -1.005 p-value: .157553
Successes: 3501 z-score: -1.005 p-value: .157553
Successes: 3467 z-score: -2.557 p-value: .005278
Successes: 3483 z-score: -1.826 p-value: .033889
square size avg. no. parked sample sigma
100. 3488.100 12.458
KSTEST for the above 10: p= 1.000000
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
Sample no. d^2 avg equiv uni
5 .6245 .6206 .466134
10 .6259 .6207 .466886
15 .6242 1.3358 .465961
20 .7586 1.1532 .533460
25 .8676 1.0802 .581848
30 .6254 1.0021 .466612
35 .7889 .9623 .547434
40 .7902 .9218 .548054
45 .7895 .8981 .547746
50 .5468 .8757 .422785
55 .5479 .8633 .423402
60 .8661 .8476 .581219
65 .7584 .9891 .533348
70 .8665 .9685 .581403
75 .5478 .9490 .423358
80 .6250 .9350 .466424
85 .5475 .9216 .423189
90 .7900 .9094 .547975
95 .5475 .8963 .423198
100 .6247 .8852 .466236
MINIMUM DISTANCE TEST for RANDOM.DAT
Result of KS test on 20 transformed mindist^2's:
p-value=1.000000
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
sample no: 1 r^3= 33.278 p-value= .67019
sample no: 2 r^3= 5.155 p-value= .15789
sample no: 3 r^3= 55.510 p-value= .84282
sample no: 4 r^3= 10.246 p-value= .28932
sample no: 5 r^3= 3.630 p-value= .11398
sample no: 6 r^3= 93.699 p-value= .95599
sample no: 7 r^3= 19.268 p-value= .47390
sample no: 8 r^3= 156.363 p-value= .99455
sample no: 9 r^3= 5.190 p-value= .15885
sample no: 10 r^3= 18.764 p-value= .46499
sample no: 11 r^3= 23.078 p-value= .53665
sample no: 12 r^3= 24.382 p-value= .55636
sample no: 13 r^3= 30.261 p-value= .63531
sample no: 14 r^3= 102.479 p-value= .96716
sample no: 15 r^3= 20.199 p-value= .48998
sample no: 16 r^3= 6.531 p-value= .19564
sample no: 17 r^3= 39.945 p-value= .73592
sample no: 18 r^3= 20.258 p-value= .49098
sample no: 19 r^3= 88.295 p-value= .94730
sample no: 20 r^3= 4.908 p-value= .15092
A KS test is applied to those 20 p-values.
---------------------------------------------------------
3DSPHERES test for file RANDOM.DAT p-value= .500917
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
Table of standardized frequency counts
( (obs-exp)/sqrt(exp) )^2
for j taking values <=6,7,8,...,47,>=48:
-.8 .9 .3 -.7 -.8 .3
-.7 -.2 .6 .8 -1.1 .5
.5 2.3 -.2 .4 -1.2 .4
-1.2 -.9 -.3 .9 -.6 -.5
-.5 .0 1.3 1.9 -.7 -.4
.5 -.8 -.1 -.5 -.6 .2
.5 -1.0 -1.6 .4 .9 .0
.8
Chi-square with 42 degrees of freedom: 30.269
z-score= -1.280 p-value= .088639
______________________________________________________________
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 .466175
Test no. 2 p-value .619766
Test no. 3 p-value .979910
Test no. 4 p-value .639836
Test no. 5 p-value .325572
Test no. 6 p-value .594480
Test no. 7 p-value .199097
Test no. 8 p-value .838390
Test no. 9 p-value .569209
Test no. 10 p-value .469628
Results of the OSUM test for RANDOM.DAT
KSTEST on the above 10 p-values: .546348
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
Up and down runs in a sample of 10000
_________________________________________________
Run test for RANDOM.DAT :
runs up; ks test for 10 p's: .976208
runs down; ks test for 10 p's: .470858
Run test for RANDOM.DAT :
runs up; ks test for 10 p's: .109378
runs down; ks test for 10 p's: .089398
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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 RANDOM.DAT
No. of wins: Observed Expected
98647 98585.86
98647= No. of wins, z-score= .273 pvalue= .60775
Analysis of Throws-per-Game:
Chisq= 16.15 for 20 degrees of freedom, p= .29244
Throws Observed Expected Chisq Sum
1 66556 66666.7 .184 .184
2 37645 37654.3 .002 .186
3 27032 26954.7 .222 .408
4 19306 19313.5 .003 .410
5 13953 13851.4 .745 1.155
6 9955 9943.5 .013 1.169
7 7154 7145.0 .011 1.180
8 5158 5139.1 .070 1.250
9 3611 3699.9 2.134 3.384
10 2703 2666.3 .505 3.889
11 1940 1923.3 .145 4.034
12 1362 1388.7 .515 4.549
13 1021 1003.7 .298 4.846
14 704 726.1 .675 5.521
15 504 525.8 .907 6.428
16 368 381.2 .454 6.882
17 262 276.5 .764 7.646
18 201 200.8 .000 7.646
19 136 146.0 .683 8.329
20 97 106.2 .800 9.129
21 332 287.1 7.017 16.145
SUMMARY FOR RANDOM.DAT
p-value for no. of wins: .607749
p-value for throws/game: .292440
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Results of DIEHARD battery
of tests sent to file cresults.txt
|