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 RandomData.bin For a sample of size 500: mean RandomData.bin using bits 1 to 24 1.996 duplicate number number spacings observed expected 0 72. 67.668 1 127. 135.335 2 140. 135.335 3 100. 90.224 4 29. 45.112 5 20. 18.045 6 to INF 12. 8.282 Chisquare with 6 d.o.f. = 9.65 p-value= .859647 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean RandomData.bin using bits 2 to 25 1.912 duplicate number number spacings observed expected 0 71. 67.668 1 143. 135.335 2 132. 135.335 3 90. 90.224 4 43. 45.112 5 19. 18.045 6 to INF 2. 8.282 Chisquare with 6 d.o.f. = 5.60 p-value= .529971 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean RandomData.bin using bits 3 to 26 1.882 duplicate number number spacings observed expected 0 75. 67.668 1 141. 135.335 2 133. 135.335 3 92. 90.224 4 43. 45.112 5 11. 18.045 6 to INF 5. 8.282 Chisquare with 6 d.o.f. = 5.26 p-value= .488640 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean RandomData.bin using bits 4 to 27 2.162 duplicate number number spacings observed expected 0 62. 67.668 1 124. 135.335 2 133. 135.335 3 92. 90.224 4 52. 45.112 5 25. 18.045 6 to INF 12. 8.282 Chisquare with 6 d.o.f. = 6.90 p-value= .669937 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean RandomData.bin using bits 5 to 28 2.038 duplicate number number spacings observed expected 0 72. 67.668 1 119. 135.335 2 139. 135.335 3 96. 90.224 4 48. 45.112 5 16. 18.045 6 to INF 10. 8.282 Chisquare with 6 d.o.f. = 3.49 p-value= .254863 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean RandomData.bin using bits 6 to 29 2.004 duplicate number number spacings observed expected 0 59. 67.668 1 130. 135.335 2 152. 135.335 3 89. 90.224 4 54. 45.112 5 12. 18.045 6 to INF 4. 8.282 Chisquare with 6 d.o.f. = 9.38 p-value= .846645 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean RandomData.bin using bits 7 to 30 2.020 duplicate number number spacings observed expected 0 56. 67.668 1 144. 135.335 2 140. 135.335 3 91. 90.224 4 44. 45.112 5 17. 18.045 6 to INF 8. 8.282 Chisquare with 6 d.o.f. = 2.83 p-value= .170320 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean RandomData.bin using bits 8 to 31 2.002 duplicate number number spacings observed expected 0 69. 67.668 1 136. 135.335 2 125. 135.335 3 101. 90.224 4 43. 45.112 5 19. 18.045 6 to INF 7. 8.282 Chisquare with 6 d.o.f. = 2.45 p-value= .126395 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean RandomData.bin using bits 9 to 32 1.970 duplicate number number spacings observed expected 0 77. 67.668 1 127. 135.335 2 140. 135.335 3 85. 90.224 4 45. 45.112 5 15. 18.045 6 to INF 11. 8.282 Chisquare with 6 d.o.f. = 3.67 p-value= .278741 ::::::::::::::::::::::::::::::::::::::::: The 9 p-values were .859647 .529971 .488640 .669937 .254863 .846645 .170320 .126395 .278741 A KSTEST for the 9 p-values yields .073032 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 RandomData.bin For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom=112.501; p-value= .833045 OPERM5 test for file RandomData.bin For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom=101.669; p-value= .593042 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 RandomData.bin Rank test for 31x31 binary matrices: rows from leftmost 31 bits of each 32-bit integer rank observed expected (o-e)^2/e sum 28 223 211.4 .634489 .634 29 5115 5134.0 .070391 .705 30 23151 23103.0 .099532 .804 31 11511 11551.5 .142165 .947 chisquare= .947 for 3 d. of f.; p-value= .351121 -------------------------------------------------------------- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 RandomData.bin Rank test for 32x32 binary matrices: rows from leftmost 32 bits of each 32-bit integer rank observed expected (o-e)^2/e sum 29 197 211.4 .983261 .983 30 5044 5134.0 1.578074 2.561 31 23180 23103.0 .256320 2.818 32 11579 11551.5 .065351 2.883 chisquare= 2.883 for 3 d. of f.; p-value= .634742 -------------------------------------------------------------- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 RandomData.bin Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 1 to 8 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 916 944.3 .848 .848 r =5 21875 21743.9 .790 1.639 r =6 77209 77311.8 .137 1.775 p=1-exp(-SUM/2)= .58839 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 2 to 9 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 987 944.3 1.931 1.931 r =5 21669 21743.9 .258 2.189 r =6 77344 77311.8 .013 2.202 p=1-exp(-SUM/2)= .66748 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 3 to 10 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 930 944.3 .217 .217 r =5 21805 21743.9 .172 .388 r =6 77265 77311.8 .028 .417 p=1-exp(-SUM/2)= .18804 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 4 to 11 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 927 944.3 .317 .317 r =5 21898 21743.9 1.092 1.409 r =6 77175 77311.8 .242 1.651 p=1-exp(-SUM/2)= .56202 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 5 to 12 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 912 944.3 1.105 1.105 r =5 21792 21743.9 .106 1.211 r =6 77296 77311.8 .003 1.215 p=1-exp(-SUM/2)= .45517 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 6 to 13 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 964 944.3 .411 .411 r =5 21664 21743.9 .294 .705 r =6 77372 77311.8 .047 .751 p=1-exp(-SUM/2)= .31319 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 7 to 14 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 928 944.3 .281 .281 r =5 21709 21743.9 .056 .337 r =6 77363 77311.8 .034 .371 p=1-exp(-SUM/2)= .16945 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 8 to 15 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 890 944.3 3.123 3.123 r =5 21762 21743.9 .015 3.138 r =6 77348 77311.8 .017 3.155 p=1-exp(-SUM/2)= .79346 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 9 to 16 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 920 944.3 .625 .625 r =5 21752 21743.9 .003 .628 r =6 77328 77311.8 .003 .632 p=1-exp(-SUM/2)= .27087 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 10 to 17 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 905 944.3 1.636 1.636 r =5 21441 21743.9 4.220 5.855 r =6 77654 77311.8 1.515 7.370 p=1-exp(-SUM/2)= .97490 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 11 to 18 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 935 944.3 .092 .092 r =5 21511 21743.9 2.495 2.586 r =6 77554 77311.8 .759 3.345 p=1-exp(-SUM/2)= .81222 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 12 to 19 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 953 944.3 .080 .080 r =5 21660 21743.9 .324 .404 r =6 77387 77311.8 .073 .477 p=1-exp(-SUM/2)= .21219 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 13 to 20 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 973 944.3 .872 .872 r =5 21426 21743.9 4.648 5.520 r =6 77601 77311.8 1.082 6.602 p=1-exp(-SUM/2)= .96315 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 14 to 21 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 951 944.3 .048 .048 r =5 21793 21743.9 .111 .158 r =6 77256 77311.8 .040 .199 p=1-exp(-SUM/2)= .09456 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 15 to 22 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 939 944.3 .030 .030 r =5 21813 21743.9 .220 .249 r =6 77248 77311.8 .053 .302 p=1-exp(-SUM/2)= .14016 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 16 to 23 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 966 944.3 .499 .499 r =5 21950 21743.9 1.954 2.452 r =6 77084 77311.8 .671 3.123 p=1-exp(-SUM/2)= .79022 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 17 to 24 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 954 944.3 .100 .100 r =5 21822 21743.9 .281 .380 r =6 77224 77311.8 .100 .480 p=1-exp(-SUM/2)= .21331 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 18 to 25 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 964 944.3 .411 .411 r =5 21874 21743.9 .778 1.189 r =6 77162 77311.8 .290 1.480 p=1-exp(-SUM/2)= .52280 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 19 to 26 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 932 944.3 .160 .160 r =5 21973 21743.9 2.414 2.574 r =6 77095 77311.8 .608 3.182 p=1-exp(-SUM/2)= .79629 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 20 to 27 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 958 944.3 .199 .199 r =5 21881 21743.9 .864 1.063 r =6 77161 77311.8 .294 1.357 p=1-exp(-SUM/2)= .49270 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 21 to 28 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 964 944.3 .411 .411 r =5 21738 21743.9 .002 .413 r =6 77298 77311.8 .002 .415 p=1-exp(-SUM/2)= .18738 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 22 to 29 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 904 944.3 1.720 1.720 r =5 21924 21743.9 1.492 3.212 r =6 77172 77311.8 .253 3.465 p=1-exp(-SUM/2)= .82312 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 23 to 30 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 928 944.3 .281 .281 r =5 21762 21743.9 .015 .296 r =6 77310 77311.8 .000 .297 p=1-exp(-SUM/2)= .13779 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 24 to 31 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 921 944.3 .575 .575 r =5 22047 21743.9 4.225 4.800 r =6 77032 77311.8 1.013 5.813 p=1-exp(-SUM/2)= .94533 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG RandomData.bin b-rank test for bits 25 to 32 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 947 944.3 .008 .008 r =5 21897 21743.9 1.078 1.086 r =6 77156 77311.8 .314 1.400 p=1-exp(-SUM/2)= .50334 TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices These should be 25 uniform [0,1] random variables: .588387 .667484 .188042 .562023 .455165 .313191 .169446 .793464 .270866 .974901 .812219 .212193 .963149 .094561 .140156 .790217 .213314 .522796 .796287 .492705 .187384 .823117 .137790 .945325 .503336 brank test summary for RandomData.bin The KS test for those 25 supposed UNI's yields KS p-value= .205325 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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: 142022 missing words, .26 sigmas from mean, p-value= .60382 tst no 2: 141986 missing words, .18 sigmas from mean, p-value= .57109 tst no 3: 142136 missing words, .53 sigmas from mean, p-value= .70181 tst no 4: 142270 missing words, .84 sigmas from mean, p-value= .80030 tst no 5: 141890 missing words, -.05 sigmas from mean, p-value= .48199 tst no 6: 141448 missing words, -1.08 sigmas from mean, p-value= .14055 tst no 7: 141807 missing words, -.24 sigmas from mean, p-value= .40552 tst no 8: 141914 missing words, .01 sigmas from mean, p-value= .50435 tst no 9: 141899 missing words, -.02 sigmas from mean, p-value= .49037 tst no 10: 142107 missing words, .46 sigmas from mean, p-value= .67791 tst no 11: 142338 missing words, 1.00 sigmas from mean, p-value= .84172 tst no 12: 141923 missing words, .03 sigmas from mean, p-value= .51274 tst no 13: 141976 missing words, .16 sigmas from mean, p-value= .56189 tst no 14: 142253 missing words, .80 sigmas from mean, p-value= .78900 tst no 15: 141859 missing words, -.12 sigmas from mean, p-value= .45320 tst no 16: 141928 missing words, .04 sigmas from mean, p-value= .51740 tst no 17: 141724 missing words, -.43 sigmas from mean, p-value= .33250 tst no 18: 141386 missing words, -1.22 sigmas from mean, p-value= .11072 tst no 19: 141491 missing words, -.98 sigmas from mean, p-value= .16419 tst no 20: 141520 missing words, -.91 sigmas from mean, p-value= .18150 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 RandomData.bin Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OPSO for RandomData.bin using bits 23 to 32 141962 .182 .5721 OPSO for RandomData.bin using bits 22 to 31 141732 -.611 .2704 OPSO for RandomData.bin using bits 21 to 30 141774 -.467 .3204 OPSO for RandomData.bin using bits 20 to 29 141990 .278 .6096 OPSO for RandomData.bin using bits 19 to 28 141425 -1.670 .0475 OPSO for RandomData.bin using bits 18 to 27 141847 -.215 .4149 OPSO for RandomData.bin using bits 17 to 26 142063 .530 .7019 OPSO for RandomData.bin using bits 16 to 25 141879 -.105 .4584 OPSO for RandomData.bin using bits 15 to 24 141874 -.122 .4515 OPSO for RandomData.bin using bits 14 to 23 141917 .026 .5106 OPSO for RandomData.bin using bits 13 to 22 142076 .575 .7173 OPSO for RandomData.bin using bits 12 to 21 141919 .033 .5133 OPSO for RandomData.bin using bits 11 to 20 142151 .833 .7977 OPSO for RandomData.bin using bits 10 to 19 141990 .278 .6096 OPSO for RandomData.bin using bits 9 to 18 141747 -.560 .2878 OPSO for RandomData.bin using bits 8 to 17 142224 1.085 .8611 OPSO for RandomData.bin using bits 7 to 16 142084 .602 .7265 OPSO for RandomData.bin using bits 6 to 15 141420 -1.687 .0458 OPSO for RandomData.bin using bits 5 to 14 142287 1.302 .9036 OPSO for RandomData.bin using bits 4 to 13 142084 .602 .7265 OPSO for RandomData.bin using bits 3 to 12 141780 -.446 .3278 OPSO for RandomData.bin using bits 2 to 11 141960 .175 .5694 OPSO for RandomData.bin using bits 1 to 10 141825 -.291 .3856 OQSO test for generator RandomData.bin Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OQSO for RandomData.bin using bits 28 to 32 141822 -.296 .3836 OQSO for RandomData.bin using bits 27 to 31 141789 -.408 .3417 OQSO for RandomData.bin using bits 26 to 30 142012 .348 .6361 OQSO for RandomData.bin using bits 25 to 29 142397 1.653 .9508 OQSO for RandomData.bin using bits 24 to 28 141838 -.242 .4045 OQSO for RandomData.bin using bits 23 to 27 141684 -.764 .2225 OQSO for RandomData.bin using bits 22 to 26 141726 -.621 .2672 OQSO for RandomData.bin using bits 21 to 25 141764 -.493 .3111 OQSO for RandomData.bin using bits 20 to 24 141648 -.886 .1878 OQSO for RandomData.bin using bits 19 to 23 141925 .053 .5212 OQSO for RandomData.bin using bits 18 to 22 142214 1.033 .8491 OQSO for RandomData.bin using bits 17 to 21 141454 -1.543 .0614 OQSO for RandomData.bin using bits 16 to 20 141508 -1.360 .0868 OQSO for RandomData.bin using bits 15 to 19 142463 1.877 .9697 OQSO for RandomData.bin using bits 14 to 18 142093 .623 .7332 OQSO for RandomData.bin using bits 13 to 17 142402 1.670 .9525 OQSO for RandomData.bin using bits 12 to 16 141856 -.181 .4283 OQSO for RandomData.bin using bits 11 to 15 141817 -.313 .3771 OQSO for RandomData.bin using bits 10 to 14 141636 -.927 .1771 OQSO for RandomData.bin using bits 9 to 13 141636 -.927 .1771 OQSO for RandomData.bin using bits 8 to 12 141949 .134 .5535 OQSO for RandomData.bin using bits 7 to 11 141690 -.743 .2286 OQSO for RandomData.bin using bits 6 to 10 142000 .307 .6207 OQSO for RandomData.bin using bits 5 to 9 141689 -.747 .2276 OQSO for RandomData.bin using bits 4 to 8 142171 .887 .8125 OQSO for RandomData.bin using bits 3 to 7 142165 .867 .8069 OQSO for RandomData.bin using bits 2 to 6 140975 -3.167 .0008 OQSO for RandomData.bin using bits 1 to 5 142423 1.741 .9592 DNA test for generator RandomData.bin Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p DNA for RandomData.bin using bits 31 to 32 141825 -.249 .4018 DNA for RandomData.bin using bits 30 to 31 142243 .984 .8375 DNA for RandomData.bin using bits 29 to 30 142222 .922 .8218 DNA for RandomData.bin using bits 28 to 29 142437 1.557 .9402 DNA for RandomData.bin using bits 27 to 28 141517 -1.157 .1236 DNA for RandomData.bin using bits 26 to 27 141856 -.157 .4375 DNA for RandomData.bin using bits 25 to 26 142131 .654 .7434 DNA for RandomData.bin using bits 24 to 25 142122 .627 .7348 DNA for RandomData.bin using bits 23 to 24 142007 .288 .6134 DNA for RandomData.bin using bits 22 to 23 141819 -.266 .3949 DNA for RandomData.bin using bits 21 to 22 141699 -.620 .2675 DNA for RandomData.bin using bits 20 to 21 142079 .501 .6916 DNA for RandomData.bin using bits 19 to 20 142125 .636 .7377 DNA for RandomData.bin using bits 18 to 19 142035 .371 .6446 DNA for RandomData.bin using bits 17 to 18 141768 -.417 .3384 DNA for RandomData.bin using bits 16 to 17 142493 1.722 .9574 DNA for RandomData.bin using bits 15 to 16 141660 -.735 .2310 DNA for RandomData.bin using bits 14 to 15 141665 -.721 .2355 DNA for RandomData.bin using bits 13 to 14 141838 -.210 .4167 DNA for RandomData.bin using bits 12 to 13 141856 -.157 .4375 DNA for RandomData.bin using bits 11 to 12 141423 -1.435 .0757 DNA for RandomData.bin using bits 10 to 11 141716 -.570 .2842 DNA for RandomData.bin using bits 9 to 10 141473 -1.287 .0990 DNA for RandomData.bin using bits 8 to 9 141929 .058 .5231 DNA for RandomData.bin using bits 7 to 8 141828 -.240 .4052 DNA for RandomData.bin using bits 6 to 7 141618 -.859 .1951 DNA for RandomData.bin using bits 5 to 6 142034 .368 .6435 DNA for RandomData.bin using bits 4 to 5 141921 .034 .5137 DNA for RandomData.bin using bits 3 to 4 141775 -.396 .3460 DNA for RandomData.bin using bits 2 to 3 142448 1.589 .9440 DNA for RandomData.bin using bits 1 to 2 142285 1.108 .8661 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 RandomData.bin Chi-square with 5^5-5^4=2500 d.of f. for sample size:2560000 chisquare equiv normal p-value Results fo COUNT-THE-1's in successive bytes: byte stream for RandomData.bin 2466.04 -.480 .315513 byte stream for RandomData.bin 2528.83 .408 .658264 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 2451.59 -.685 .246791 bits 2 to 9 2484.04 -.226 .410692 bits 3 to 10 2600.07 1.415 .921493 bits 4 to 11 2576.95 1.088 .861742 bits 5 to 12 2591.55 1.295 .902288 bits 6 to 13 2547.49 .672 .749076 bits 7 to 14 2604.63 1.480 .930530 bits 8 to 15 2393.24 -1.510 .065545 bits 9 to 16 2485.58 -.204 .419189 bits 10 to 17 2467.87 -.454 .324794 bits 11 to 18 2457.32 -.604 .273067 bits 12 to 19 2535.12 .497 .690292 bits 13 to 20 2415.93 -1.189 .117236 bits 14 to 21 2575.43 1.067 .856968 bits 15 to 22 2442.44 -.814 .207828 bits 16 to 23 2605.96 1.499 .933005 bits 17 to 24 2492.76 -.102 .459236 bits 18 to 25 2483.63 -.232 .408448 bits 19 to 26 2609.87 1.554 .939891 bits 20 to 27 2560.04 .849 .802072 bits 21 to 28 2365.43 -1.903 .028515 bits 22 to 29 2593.00 1.315 .905784 bits 23 to 30 2533.99 .481 .684646 bits 24 to 31 2435.76 -.908 .181822 bits 25 to 32 2513.19 .187 .573976 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 RandomData.bin Of 12,000 tries, the average no. of successes should be 3523 with sigma=21.9 Successes: 3503 z-score: -.913 p-value: .180558 Successes: 3511 z-score: -.548 p-value: .291865 Successes: 3497 z-score: -1.187 p-value: .117571 Successes: 3526 z-score: .137 p-value: .554479 Successes: 3551 z-score: 1.279 p-value: .899470 Successes: 3538 z-score: .685 p-value: .753306 Successes: 3485 z-score: -1.735 p-value: .041356 Successes: 3526 z-score: .137 p-value: .554479 Successes: 3551 z-score: 1.279 p-value: .899470 Successes: 3554 z-score: 1.416 p-value: .921543 square size avg. no. parked sample sigma 100. 3524.200 23.289 KSTEST for the above 10: p= .201923 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 RandomData.bin Sample no. d^2 avg equiv uni 5 .0532 .3048 .052029 10 .4513 .5476 .364657 15 1.1647 .6576 .689818 20 .5922 .9822 .448542 25 .3134 1.0098 .270227 30 .1026 .9346 .097982 35 1.1021 .9698 .669673 40 .1867 .9572 .171052 45 .1999 .9244 .181974 50 1.8897 .9473 .850312 55 .4816 .9652 .383701 60 1.3336 .9497 .738244 65 .7650 .9774 .536431 70 .2600 .9563 .229980 75 1.0772 .9527 .661298 80 .3672 .9546 .308581 85 .9947 .9410 .632003 90 2.6625 .9319 .931156 95 1.2102 .9526 .703656 100 .3203 .9274 .275272 MINIMUM DISTANCE TEST for RandomData.bin Result of KS test on 20 transformed mindist^2's: p-value= .366588 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 RandomData.bin sample no: 1 r^3= 9.830 p-value= .27939 sample no: 2 r^3= .554 p-value= .01829 sample no: 3 r^3= 9.583 p-value= .27343 sample no: 4 r^3= 10.168 p-value= .28747 sample no: 5 r^3= 9.825 p-value= .27928 sample no: 6 r^3= 30.225 p-value= .63487 sample no: 7 r^3= 15.380 p-value= .40111 sample no: 8 r^3= .833 p-value= .02737 sample no: 9 r^3= 22.759 p-value= .53170 sample no: 10 r^3= 72.798 p-value= .91166 sample no: 11 r^3= 4.050 p-value= .12628 sample no: 12 r^3= 23.441 p-value= .54222 sample no: 13 r^3= 67.136 p-value= .89331 sample no: 14 r^3= 136.970 p-value= .98960 sample no: 15 r^3= 73.270 p-value= .91304 sample no: 16 r^3= 21.106 p-value= .50516 sample no: 17 r^3= 6.074 p-value= .18329 sample no: 18 r^3= 14.822 p-value= .38987 sample no: 19 r^3= 9.227 p-value= .26477 sample no: 20 r^3= 71.084 p-value= .90647 A KS test is applied to those 20 p-values. --------------------------------------------------------- 3DSPHERES test for file RandomData.bin p-value= .457909 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 RandomData.bin Table of standardized frequency counts ( (obs-exp)/sqrt(exp) )^2 for j taking values <=6,7,8,...,47,>=48: -.1 1.8 -1.8 3.0 -.7 -.7 .0 -.9 -.7 .6 .4 1.0 .5 -.1 .3 1.1 1.3 -.8 .6 -1.3 .3 -1.4 -1.1 -.4 -.1 -.4 -1.5 -.8 1.4 .4 .7 .6 .4 .5 -.1 -.1 .5 -.4 -.8 1.0 .1 -1.0 -.1 Chi-square with 42 degrees of freedom: 37.392 z-score= -.503 p-value= .326493 ______________________________________________________________ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 .764181 Test no. 2 p-value .088711 Test no. 3 p-value .851642 Test no. 4 p-value .826001 Test no. 5 p-value .089337 Test no. 6 p-value .726868 Test no. 7 p-value .077312 Test no. 8 p-value .995722 Test no. 9 p-value .080019 Test no. 10 p-value .715659 Results of the OSUM test for RandomData.bin KSTEST on the above 10 p-values: .844934 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 RandomData.bin Up and down runs in a sample of 10000 _________________________________________________ Run test for RandomData.bin : runs up; ks test for 10 p's: .671789 runs down; ks test for 10 p's: .846466 Run test for RandomData.bin : runs up; ks test for 10 p's: .469168 runs down; ks test for 10 p's: .337606 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 RandomData.bin No. of wins: Observed Expected 98477 98585.86 98477= No. of wins, z-score= -.487 pvalue= .31317 Analysis of Throws-per-Game: Chisq= 24.72 for 20 degrees of freedom, p= .78767 Throws Observed Expected Chisq Sum 1 66731 66666.7 .062 .062 2 37455 37654.3 1.055 1.117 3 26815 26954.7 .724 1.842 4 19340 19313.5 .036 1.878 5 13932 13851.4 .469 2.347 6 9976 9943.5 .106 2.453 7 7294 7145.0 3.106 5.559 8 5128 5139.1 .024 5.583 9 3841 3699.9 5.384 10.967 10 2625 2666.3 .640 11.606 11 1899 1923.3 .308 11.914 12 1376 1388.7 .117 12.031 13 1015 1003.7 .127 12.158 14 666 726.1 4.981 17.139 15 538 525.8 .281 17.420 16 369 381.2 .387 17.807 17 303 276.5 2.532 20.339 18 178 200.8 2.595 22.934 19 134 146.0 .984 23.918 20 97 106.2 .800 24.718 21 288 287.1 .003 24.721 SUMMARY FOR RandomData.bin p-value for no. of wins: .313171 p-value for throws/game: .787668 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Results of DIEHARD battery of tests sent to file Output.txt