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 temp.txt For a sample of size 500: mean temp.txt using bits 1 to 24 2.012 duplicate number number spacings observed expected 0 72. 67.668 1 132. 135.335 2 128. 135.335 3 87. 90.224 4 55. 45.112 5 19. 18.045 6 to INF 7. 8.282 Chisquare with 6 d.o.f. = 3.29 p-value= .228168 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean temp.txt using bits 2 to 25 2.054 duplicate number number spacings observed expected 0 70. 67.668 1 123. 135.335 2 128. 135.335 3 103. 90.224 4 52. 45.112 5 16. 18.045 6 to INF 8. 8.282 Chisquare with 6 d.o.f. = 4.70 p-value= .417783 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean temp.txt using bits 3 to 26 1.984 duplicate number number spacings observed expected 0 65. 67.668 1 145. 135.335 2 130. 135.335 3 93. 90.224 4 42. 45.112 5 16. 18.045 6 to INF 9. 8.282 Chisquare with 6 d.o.f. = 1.60 p-value= .047404 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean temp.txt using bits 4 to 27 1.960 duplicate number number spacings observed expected 0 74. 67.668 1 135. 135.335 2 133. 135.335 3 88. 90.224 4 48. 45.112 5 13. 18.045 6 to INF 9. 8.282 Chisquare with 6 d.o.f. = 2.35 p-value= .114715 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean temp.txt using bits 5 to 28 1.936 duplicate number number spacings observed expected 0 66. 67.668 1 140. 135.335 2 141. 135.335 3 91. 90.224 4 45. 45.112 5 9. 18.045 6 to INF 8. 8.282 Chisquare with 6 d.o.f. = 4.99 p-value= .454787 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean temp.txt using bits 6 to 29 2.008 duplicate number number spacings observed expected 0 67. 67.668 1 132. 135.335 2 145. 135.335 3 84. 90.224 4 41. 45.112 5 22. 18.045 6 to INF 9. 8.282 Chisquare with 6 d.o.f. = 2.51 p-value= .132911 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean temp.txt using bits 7 to 30 2.010 duplicate number number spacings observed expected 0 72. 67.668 1 129. 135.335 2 133. 135.335 3 90. 90.224 4 51. 45.112 5 17. 18.045 6 to INF 8. 8.282 Chisquare with 6 d.o.f. = 1.45 p-value= .037472 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean temp.txt using bits 8 to 31 1.948 duplicate number number spacings observed expected 0 85. 67.668 1 128. 135.335 2 117. 135.335 3 100. 90.224 4 45. 45.112 5 19. 18.045 6 to INF 6. 8.282 Chisquare with 6 d.o.f. = 9.06 p-value= .829771 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean temp.txt using bits 9 to 32 2.096 duplicate number number spacings observed expected 0 56. 67.668 1 134. 135.335 2 136. 135.335 3 100. 90.224 4 44. 45.112 5 20. 18.045 6 to INF 10. 8.282 Chisquare with 6 d.o.f. = 3.68 p-value= .280562 ::::::::::::::::::::::::::::::::::::::::: The 9 p-values were .228168 .417783 .047404 .114715 .454787 .132911 .037472 .829771 .280562 A KSTEST for the 9 p-values yields .966557 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 temp.txt For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom= 89.945; p-value= .268684 OPERM5 test for file temp.txt For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom= 98.014; p-value= .490866 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 temp.txt 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 203 211.4 .335179 .335 29 5130 5134.0 .003132 .338 30 22992 23103.0 .533757 .872 31 11675 11551.5 1.319845 2.192 chisquare= 2.192 for 3 d. of f.; p-value= .535826 -------------------------------------------------------------- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 temp.txt 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 217 211.4 .147379 .147 30 5114 5134.0 .077992 .225 31 23023 23103.0 .277344 .503 32 11646 11551.5 .772680 1.275 chisquare= 1.275 for 3 d. of f.; p-value= .394395 -------------------------------------------------------------- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 temp.txt Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 1 to 8 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 975 944.3 .998 .998 r =5 21861 21743.9 .631 1.629 r =6 77164 77311.8 .283 1.911 p=1-exp(-SUM/2)= .61542 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 2 to 9 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 1015 944.3 5.293 5.293 r =5 21695 21743.9 .110 5.403 r =6 77290 77311.8 .006 5.409 p=1-exp(-SUM/2)= .93310 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 3 to 10 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 995 944.3 2.722 2.722 r =5 21723 21743.9 .020 2.742 r =6 77282 77311.8 .011 2.754 p=1-exp(-SUM/2)= .74761 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 4 to 11 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 946 944.3 .003 .003 r =5 21907 21743.9 1.223 1.226 r =6 77147 77311.8 .351 1.578 p=1-exp(-SUM/2)= .54565 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 5 to 12 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 926 944.3 .355 .355 r =5 21886 21743.9 .929 1.283 r =6 77188 77311.8 .198 1.482 p=1-exp(-SUM/2)= .52327 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 6 to 13 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 963 944.3 .370 .370 r =5 21553 21743.9 1.676 2.046 r =6 77484 77311.8 .384 2.430 p=1-exp(-SUM/2)= .70326 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 7 to 14 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 872 944.3 5.536 5.536 r =5 21658 21743.9 .339 5.875 r =6 77470 77311.8 .324 6.199 p=1-exp(-SUM/2)= .95493 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 8 to 15 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 922 944.3 .527 .527 r =5 21721 21743.9 .024 .551 r =6 77357 77311.8 .026 .577 p=1-exp(-SUM/2)= .25070 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 9 to 16 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 892 944.3 2.897 2.897 r =5 21948 21743.9 1.916 4.813 r =6 77160 77311.8 .298 5.111 p=1-exp(-SUM/2)= .92233 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 10 to 17 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 909 944.3 1.320 1.320 r =5 21845 21743.9 .470 1.790 r =6 77246 77311.8 .056 1.846 p=1-exp(-SUM/2)= .60263 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 11 to 18 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 960 944.3 .261 .261 r =5 21874 21743.9 .778 1.039 r =6 77166 77311.8 .275 1.314 p=1-exp(-SUM/2)= .48170 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 12 to 19 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 955 944.3 .121 .121 r =5 21689 21743.9 .139 .260 r =6 77356 77311.8 .025 .285 p=1-exp(-SUM/2)= .13285 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 13 to 20 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 1021 944.3 6.230 6.230 r =5 21518 21743.9 2.347 8.577 r =6 77461 77311.8 .288 8.865 p=1-exp(-SUM/2)= .98811 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 14 to 21 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 907 944.3 1.473 1.473 r =5 21694 21743.9 .115 1.588 r =6 77399 77311.8 .098 1.686 p=1-exp(-SUM/2)= .56965 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 15 to 22 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 941 944.3 .012 .012 r =5 21612 21743.9 .800 .812 r =6 77447 77311.8 .236 1.048 p=1-exp(-SUM/2)= .40788 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 16 to 23 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 958 944.3 .199 .199 r =5 21792 21743.9 .106 .305 r =6 77250 77311.8 .049 .355 p=1-exp(-SUM/2)= .16244 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 17 to 24 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 920 944.3 .625 .625 r =5 21831 21743.9 .349 .974 r =6 77249 77311.8 .051 1.025 p=1-exp(-SUM/2)= .40109 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 18 to 25 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 917 944.3 .789 .789 r =5 21636 21743.9 .535 1.325 r =6 77447 77311.8 .236 1.561 p=1-exp(-SUM/2)= .54186 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 19 to 26 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 943 944.3 .002 .002 r =5 21523 21743.9 2.244 2.246 r =6 77534 77311.8 .639 2.885 p=1-exp(-SUM/2)= .76361 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 20 to 27 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 956 944.3 .145 .145 r =5 21541 21743.9 1.893 2.038 r =6 77503 77311.8 .473 2.511 p=1-exp(-SUM/2)= .71508 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 21 to 28 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 924 944.3 .436 .436 r =5 21535 21743.9 2.007 2.443 r =6 77541 77311.8 .679 3.123 p=1-exp(-SUM/2)= .79017 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 22 to 29 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 923 944.3 .481 .481 r =5 21593 21743.9 1.047 1.528 r =6 77484 77311.8 .384 1.911 p=1-exp(-SUM/2)= .61543 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 23 to 30 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 928 944.3 .281 .281 r =5 21598 21743.9 .979 1.260 r =6 77474 77311.8 .340 1.601 p=1-exp(-SUM/2)= .55082 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 24 to 31 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 897 944.3 2.369 2.369 r =5 21759 21743.9 .010 2.380 r =6 77344 77311.8 .013 2.393 p=1-exp(-SUM/2)= .69779 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG temp.txt b-rank test for bits 25 to 32 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 922 944.3 .527 .527 r =5 21790 21743.9 .098 .624 r =6 77288 77311.8 .007 .632 p=1-exp(-SUM/2)= .27085 TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices These should be 25 uniform [0,1] random variables: .615419 .933105 .747609 .545648 .523266 .703261 .954925 .250696 .922332 .602628 .481696 .132853 .988112 .569650 .407876 .162443 .401094 .541864 .763611 .715082 .790167 .615432 .550820 .697791 .270849 brank test summary for temp.txt The KS test for those 25 supposed UNI's yields KS p-value= .898237 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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: 142119 missing words, .49 sigmas from mean, p-value= .68789 tst no 2: 141722 missing words, -.44 sigmas from mean, p-value= .33081 tst no 3: 141087 missing words, -1.92 sigmas from mean, p-value= .02735 tst no 4: 142264 missing words, .83 sigmas from mean, p-value= .79636 tst no 5: 141717 missing words, -.45 sigmas from mean, p-value= .32658 tst no 6: 141260 missing words, -1.52 sigmas from mean, p-value= .06462 tst no 7: 141469 missing words, -1.03 sigmas from mean, p-value= .15179 tst no 8: 141821 missing words, -.21 sigmas from mean, p-value= .41825 tst no 9: 141609 missing words, -.70 sigmas from mean, p-value= .24143 tst no 10: 141216 missing words, -1.62 sigmas from mean, p-value= .05262 tst no 11: 141911 missing words, .00 sigmas from mean, p-value= .50156 tst no 12: 141586 missing words, -.76 sigmas from mean, p-value= .22499 tst no 13: 141819 missing words, -.21 sigmas from mean, p-value= .41643 tst no 14: 141648 missing words, -.61 sigmas from mean, p-value= .27074 tst no 15: 141361 missing words, -1.28 sigmas from mean, p-value= .10007 tst no 16: 141686 missing words, -.52 sigmas from mean, p-value= .30091 tst no 17: 141666 missing words, -.57 sigmas from mean, p-value= .28484 tst no 18: 142244 missing words, .78 sigmas from mean, p-value= .78288 tst no 19: 142183 missing words, .64 sigmas from mean, p-value= .73873 tst no 20: 141780 missing words, -.30 sigmas from mean, p-value= .38126 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 temp.txt Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OPSO for temp.txt using bits 23 to 32 141991 .282 .6109 OPSO for temp.txt using bits 22 to 31 142181 .937 .8256 OPSO for temp.txt using bits 21 to 30 141892 -.060 .4762 OPSO for temp.txt using bits 20 to 29 142137 .785 .7838 OPSO for temp.txt using bits 19 to 28 142641 2.523 .9942 OPSO for temp.txt using bits 18 to 27 142182 .940 .8265 OPSO for temp.txt using bits 17 to 26 142209 1.033 .8493 OPSO for temp.txt using bits 16 to 25 141935 .089 .5353 OPSO for temp.txt using bits 15 to 24 141781 -.443 .3291 OPSO for temp.txt using bits 14 to 23 141673 -.815 .2076 OPSO for temp.txt using bits 13 to 22 141582 -1.129 .1295 OPSO for temp.txt using bits 12 to 21 142529 2.137 .9837 OPSO for temp.txt using bits 11 to 20 141897 -.043 .4830 OPSO for temp.txt using bits 10 to 19 141759 -.518 .3021 OPSO for temp.txt using bits 9 to 18 142225 1.089 .8618 OPSO for temp.txt using bits 8 to 17 142012 .354 .6383 OPSO for temp.txt using bits 7 to 16 142709 2.757 .9971 OPSO for temp.txt using bits 6 to 15 142277 1.268 .8976 OPSO for temp.txt using bits 5 to 14 142035 .433 .6676 OPSO for temp.txt using bits 4 to 13 141581 -1.132 .1288 OPSO for temp.txt using bits 3 to 12 142151 .833 .7977 OPSO for temp.txt using bits 2 to 11 141847 -.215 .4149 OPSO for temp.txt using bits 1 to 10 142476 1.954 .9747 OQSO test for generator temp.txt Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OQSO for temp.txt using bits 28 to 32 142324 1.406 .9201 OQSO for temp.txt using bits 27 to 31 141911 .006 .5023 OQSO for temp.txt using bits 26 to 30 142165 .867 .8069 OQSO for temp.txt using bits 25 to 29 142042 .450 .6735 OQSO for temp.txt using bits 24 to 28 142470 1.901 .9713 OQSO for temp.txt using bits 23 to 27 141518 -1.327 .0923 OQSO for temp.txt using bits 22 to 26 142202 .992 .8394 OQSO for temp.txt using bits 21 to 25 141557 -1.194 .1162 OQSO for temp.txt using bits 20 to 24 142536 2.124 .9832 OQSO for temp.txt using bits 19 to 23 141746 -.554 .2899 OQSO for temp.txt using bits 18 to 22 142100 .646 .7410 OQSO for temp.txt using bits 17 to 21 141774 -.459 .3232 OQSO for temp.txt using bits 16 to 20 142082 .585 .7208 OQSO for temp.txt using bits 15 to 19 142255 1.172 .8794 OQSO for temp.txt using bits 14 to 18 141763 -.496 .3099 OQSO for temp.txt using bits 13 to 17 141767 -.482 .3147 OQSO for temp.txt using bits 12 to 16 141881 -.096 .4617 OQSO for temp.txt using bits 11 to 15 141631 -.943 .1727 OQSO for temp.txt using bits 10 to 14 141525 -1.303 .0963 OQSO for temp.txt using bits 9 to 13 141708 -.682 .2475 OQSO for temp.txt using bits 8 to 12 141656 -.859 .1952 OQSO for temp.txt using bits 7 to 11 141891 -.062 .4752 OQSO for temp.txt using bits 6 to 10 141633 -.937 .1745 OQSO for temp.txt using bits 5 to 9 141735 -.591 .2773 OQSO for temp.txt using bits 4 to 8 141925 .053 .5212 OQSO for temp.txt using bits 3 to 7 142182 .924 .8223 OQSO for temp.txt using bits 2 to 6 141791 -.401 .3442 OQSO for temp.txt using bits 1 to 5 141686 -.757 .2245 DNA test for generator temp.txt Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p DNA for temp.txt using bits 31 to 32 142163 .748 .7729 DNA for temp.txt using bits 30 to 31 141795 -.337 .3680 DNA for temp.txt using bits 29 to 30 141748 -.476 .3171 DNA for temp.txt using bits 28 to 29 142377 1.380 .9161 DNA for temp.txt using bits 27 to 28 142172 .775 .7808 DNA for temp.txt using bits 26 to 27 141850 -.175 .4305 DNA for temp.txt using bits 25 to 26 141868 -.122 .4515 DNA for temp.txt using bits 24 to 25 141968 .173 .5687 DNA for temp.txt using bits 23 to 24 141672 -.700 .2419 DNA for temp.txt using bits 22 to 23 141932 .067 .5267 DNA for temp.txt using bits 21 to 22 141823 -.255 .3995 DNA for temp.txt using bits 20 to 21 141246 -1.957 .0252 DNA for temp.txt using bits 19 to 20 142412 1.483 .9309 DNA for temp.txt using bits 18 to 19 141880 -.087 .4655 DNA for temp.txt using bits 17 to 18 142554 1.902 .9714 DNA for temp.txt using bits 16 to 17 141925 .046 .5184 DNA for temp.txt using bits 15 to 16 141514 -1.166 .1218 DNA for temp.txt using bits 14 to 15 141575 -.986 .1620 DNA for temp.txt using bits 13 to 14 142109 .589 .7221 DNA for temp.txt using bits 12 to 13 142522 1.807 .9646 DNA for temp.txt using bits 11 to 12 141988 .232 .5918 DNA for temp.txt using bits 10 to 11 141778 -.387 .3492 DNA for temp.txt using bits 9 to 10 142188 .822 .7945 DNA for temp.txt using bits 8 to 9 142201 .860 .8052 DNA for temp.txt using bits 7 to 8 141382 -1.556 .0599 DNA for temp.txt using bits 6 to 7 141676 -.688 .2456 DNA for temp.txt using bits 5 to 6 141687 -.656 .2560 DNA for temp.txt using bits 4 to 5 141515 -1.163 .1224 DNA for temp.txt using bits 3 to 4 141504 -1.196 .1159 DNA for temp.txt using bits 2 to 3 141195 -2.107 .0176 DNA for temp.txt using bits 1 to 2 141258 -1.921 .0273 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 temp.txt 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 temp.txt 2422.84 -1.091 .137597 byte stream for temp.txt 2513.78 .195 .577236 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 2573.26 1.036 .849917 bits 2 to 9 2607.97 1.527 .936615 bits 3 to 10 2645.52 2.058 .980203 bits 4 to 11 2583.54 1.181 .881288 bits 5 to 12 2476.67 -.330 .370723 bits 6 to 13 2392.93 -1.514 .064981 bits 7 to 14 2529.80 .421 .663271 bits 8 to 15 2575.56 1.069 .857356 bits 9 to 16 2495.17 -.068 .472789 bits 10 to 17 2403.53 -1.364 .086248 bits 11 to 18 2574.54 1.054 .854096 bits 12 to 19 2463.98 -.509 .305224 bits 13 to 20 2564.56 .913 .819383 bits 14 to 21 2565.09 .920 .821337 bits 15 to 22 2543.51 .615 .730809 bits 16 to 23 2485.32 -.208 .417782 bits 17 to 24 2449.86 -.709 .239118 bits 18 to 25 2441.84 -.822 .205410 bits 19 to 26 2589.01 1.259 .895945 bits 20 to 27 2508.05 .114 .545347 bits 21 to 28 2552.58 .744 .771427 bits 22 to 29 2491.86 -.115 .454169 bits 23 to 30 2422.03 -1.103 .135079 bits 24 to 31 2365.03 -1.909 .028149 bits 25 to 32 2492.37 -.108 .457039 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 temp.txt Of 12,000 tries, the average no. of successes should be 3523 with sigma=21.9 Successes: 3567 z-score: 2.009 p-value: .977738 Successes: 3524 z-score: .046 p-value: .518210 Successes: 3519 z-score: -.183 p-value: .427537 Successes: 3572 z-score: 2.237 p-value: .987371 Successes: 3523 z-score: .000 p-value: .500000 Successes: 3574 z-score: 2.329 p-value: .990064 Successes: 3503 z-score: -.913 p-value: .180558 Successes: 3511 z-score: -.548 p-value: .291865 Successes: 3547 z-score: 1.096 p-value: .863437 Successes: 3485 z-score: -1.735 p-value: .041356 square size avg. no. parked sample sigma 100. 3532.500 29.349 KSTEST for the above 10: p= .882309 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 temp.txt Sample no. d^2 avg equiv uni 5 2.7866 1.2433 .939225 10 2.2537 1.1003 .896171 15 5.1447 1.2816 .994319 20 2.0274 1.2039 .869655 25 1.5664 1.0692 .792844 30 2.8431 1.0621 .942580 35 .5992 1.0099 .452389 40 .5979 .9635 .451683 45 1.5684 .9649 .793256 50 .1484 .9355 .138563 55 .4638 .9238 .372584 60 .6344 .9398 .471457 65 2.1082 .9211 .879824 70 1.2272 .9224 .708702 75 1.0560 .9457 .653987 80 .3090 .9193 .266931 85 2.3783 .9256 .908397 90 1.5617 .9116 .791863 95 1.1725 .8980 .692215 100 .0507 .8938 .049640 MINIMUM DISTANCE TEST for temp.txt Result of KS test on 20 transformed mindist^2's: p-value= .461085 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 temp.txt sample no: 1 r^3= 24.657 p-value= .56041 sample no: 2 r^3= 102.421 p-value= .96709 sample no: 3 r^3= 14.718 p-value= .38774 sample no: 4 r^3= 35.344 p-value= .69215 sample no: 5 r^3= 43.196 p-value= .76304 sample no: 6 r^3= 40.066 p-value= .73698 sample no: 7 r^3= 42.536 p-value= .75777 sample no: 8 r^3= 23.189 p-value= .53836 sample no: 9 r^3= 5.247 p-value= .16045 sample no: 10 r^3= 46.850 p-value= .79022 sample no: 11 r^3= 1.377 p-value= .04487 sample no: 12 r^3= 195.066 p-value= .99850 sample no: 13 r^3= 77.842 p-value= .92533 sample no: 14 r^3= 44.910 p-value= .77620 sample no: 15 r^3= 27.148 p-value= .59544 sample no: 16 r^3= 99.502 p-value= .96373 sample no: 17 r^3= 2.983 p-value= .09464 sample no: 18 r^3= 30.557 p-value= .63889 sample no: 19 r^3= 95.739 p-value= .95888 sample no: 20 r^3= 7.092 p-value= .21054 A KS test is applied to those 20 p-values. --------------------------------------------------------- 3DSPHERES test for file temp.txt p-value= .955590 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 temp.txt Table of standardized frequency counts ( (obs-exp)/sqrt(exp) )^2 for j taking values <=6,7,8,...,47,>=48: .6 .5 -.4 .2 .8 -.3 1.1 2.1 -1.2 -.3 .4 .8 -2.1 -.4 .0 -2.5 .6 1.6 -1.2 1.4 .7 .4 1.8 -1.1 -.6 -1.7 .9 -.8 .1 1.3 -.5 2.0 .1 .8 -2.4 1.1 1.2 1.5 -.8 -.1 -1.3 -1.0 -1.1 Chi-square with 42 degrees of freedom: 57.750 z-score= 1.718 p-value= .946554 ______________________________________________________________ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 .511978 Test no. 2 p-value .731426 Test no. 3 p-value .206525 Test no. 4 p-value .119025 Test no. 5 p-value .576686 Test no. 6 p-value .499780 Test no. 7 p-value .637645 Test no. 8 p-value .043383 Test no. 9 p-value .175523 Test no. 10 p-value .231362 Results of the OSUM test for temp.txt KSTEST on the above 10 p-values: .744704 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 temp.txt Up and down runs in a sample of 10000 _________________________________________________ Run test for temp.txt : runs up; ks test for 10 p's: .817847 runs down; ks test for 10 p's: .724831 Run test for temp.txt : runs up; ks test for 10 p's: .400115 runs down; ks test for 10 p's: .747420 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 temp.txt No. of wins: Observed Expected 98265 98585.86 98265= No. of wins, z-score=-1.435 pvalue= .07563 Analysis of Throws-per-Game: Chisq= 18.75 for 20 degrees of freedom, p= .46186 Throws Observed Expected Chisq Sum 1 66611 66666.7 .046 .046 2 37417 37654.3 1.496 1.542 3 26972 26954.7 .011 1.553 4 19383 19313.5 .250 1.804 5 13838 13851.4 .013 1.817 6 9999 9943.5 .309 2.126 7 7172 7145.0 .102 2.228 8 5141 5139.1 .001 2.229 9 3822 3699.9 4.032 6.260 10 2637 2666.3 .322 6.582 11 1951 1923.3 .398 6.980 12 1398 1388.7 .062 7.042 13 1040 1003.7 1.312 8.354 14 688 726.1 2.003 10.357 15 489 525.8 2.580 12.938 16 377 381.2 .045 12.983 17 266 276.5 .402 13.384 18 226 200.8 3.155 16.539 19 155 146.0 .557 17.096 20 110 106.2 .135 17.231 21 308 287.1 1.519 18.750 SUMMARY FOR temp.txt p-value for no. of wins: .075634 p-value for throws/game: .461864 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Results of DIEHARD battery of tests sent to file kekka.txt