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 randnumb.bin For a sample of size 500: mean randnumb.bin using bits 1 to 24 1.950 duplicate number number spacings observed expected 0 66. 67.668 1 146. 135.335 2 135. 135.335 3 86. 90.224 4 44. 45.112 5 15. 18.045 6 to INF 8. 8.282 Chisquare with 6 d.o.f. = 1.63 p-value= .049660 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean randnumb.bin using bits 2 to 25 1.910 duplicate number number spacings observed expected 0 78. 67.668 1 139. 135.335 2 136. 135.335 3 88. 90.224 4 30. 45.112 5 20. 18.045 6 to INF 9. 8.282 Chisquare with 6 d.o.f. = 7.07 p-value= .685700 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean randnumb.bin using bits 3 to 26 1.964 duplicate number number spacings observed expected 0 79. 67.668 1 128. 135.335 2 128. 135.335 3 97. 90.224 4 43. 45.112 5 19. 18.045 6 to INF 6. 8.282 Chisquare with 6 d.o.f. = 3.98 p-value= .320627 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean randnumb.bin using bits 4 to 27 1.918 duplicate number number spacings observed expected 0 69. 67.668 1 141. 135.335 2 137. 135.335 3 92. 90.224 4 41. 45.112 5 17. 18.045 6 to INF 3. 8.282 Chisquare with 6 d.o.f. = 4.12 p-value= .339908 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean randnumb.bin using bits 5 to 28 2.054 duplicate number number spacings observed expected 0 64. 67.668 1 117. 135.335 2 147. 135.335 3 103. 90.224 4 44. 45.112 5 20. 18.045 6 to INF 5. 8.282 Chisquare with 6 d.o.f. = 7.04 p-value= .682586 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean randnumb.bin using bits 6 to 29 1.998 duplicate number number spacings observed expected 0 67. 67.668 1 133. 135.335 2 146. 135.335 3 82. 90.224 4 47. 45.112 5 11. 18.045 6 to INF 14. 8.282 Chisquare with 6 d.o.f. = 8.41 p-value= .790704 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean randnumb.bin using bits 7 to 30 1.990 duplicate number number spacings observed expected 0 68. 67.668 1 140. 135.335 2 123. 135.335 3 98. 90.224 4 46. 45.112 5 20. 18.045 6 to INF 5. 8.282 Chisquare with 6 d.o.f. = 3.49 p-value= .254279 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean randnumb.bin using bits 8 to 31 1.952 duplicate number number spacings observed expected 0 70. 67.668 1 135. 135.335 2 140. 135.335 3 88. 90.224 4 43. 45.112 5 19. 18.045 6 to INF 5. 8.282 Chisquare with 6 d.o.f. = 1.75 p-value= .058541 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean randnumb.bin using bits 9 to 32 1.964 duplicate number number spacings observed expected 0 73. 67.668 1 134. 135.335 2 137. 135.335 3 86. 90.224 4 49. 45.112 5 13. 18.045 6 to INF 8. 8.282 Chisquare with 6 d.o.f. = 2.41 p-value= .121231 ::::::::::::::::::::::::::::::::::::::::: The 9 p-values were .049660 .685700 .320627 .339908 .682586 .790704 .254279 .058541 .121231 A KSTEST for the 9 p-values yields .749450 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 randnumb.bin For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom= 76.246; p-value= .043421 OPERM5 test for file randnumb.bin For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom= 94.180; p-value= .381748 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 randnumb.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 210 211.4 .009511 .010 29 5099 5134.0 .238745 .248 30 23160 23103.0 .140400 .389 31 11531 11551.5 .036467 .425 chisquare= .425 for 3 d. of f.; p-value= .322191 -------------------------------------------------------------- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 randnumb.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 212 211.4 .001602 .002 30 5102 5134.0 .199582 .201 31 23150 23103.0 .095424 .297 32 11536 11551.5 .020864 .317 chisquare= .317 for 3 d. of f.; p-value= .329856 -------------------------------------------------------------- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 randnumb.bin Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 1 to 8 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 912 944.3 1.105 1.105 r =5 21815 21743.9 .232 1.337 r =6 77273 77311.8 .019 1.357 p=1-exp(-SUM/2)= .49259 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 2 to 9 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 929 944.3 .248 .248 r =5 21777 21743.9 .050 .298 r =6 77294 77311.8 .004 .302 p=1-exp(-SUM/2)= .14033 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 3 to 10 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 971 944.3 .755 .755 r =5 21858 21743.9 .599 1.354 r =6 77171 77311.8 .256 1.610 p=1-exp(-SUM/2)= .55292 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 4 to 11 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 950 944.3 .034 .034 r =5 21864 21743.9 .663 .698 r =6 77186 77311.8 .205 .902 p=1-exp(-SUM/2)= .36316 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 5 to 12 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 929 944.3 .248 .248 r =5 21574 21743.9 1.328 1.575 r =6 77497 77311.8 .444 2.019 p=1-exp(-SUM/2)= .63562 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 6 to 13 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 999 944.3 3.168 3.168 r =5 21633 21743.9 .566 3.734 r =6 77368 77311.8 .041 3.775 p=1-exp(-SUM/2)= .84854 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 7 to 14 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 927 944.3 .317 .317 r =5 21738 21743.9 .002 .319 r =6 77335 77311.8 .007 .326 p=1-exp(-SUM/2)= .15022 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 8 to 15 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 919 944.3 .678 .678 r =5 21595 21743.9 1.020 1.698 r =6 77486 77311.8 .392 2.090 p=1-exp(-SUM/2)= .64832 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 9 to 16 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 953 944.3 .080 .080 r =5 21597 21743.9 .992 1.073 r =6 77450 77311.8 .247 1.320 p=1-exp(-SUM/2)= .48305 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 10 to 17 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 983 944.3 1.586 1.586 r =5 21724 21743.9 .018 1.604 r =6 77293 77311.8 .005 1.609 p=1-exp(-SUM/2)= .55262 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 11 to 18 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 967 944.3 .546 .546 r =5 21981 21743.9 2.585 3.131 r =6 77052 77311.8 .873 4.004 p=1-exp(-SUM/2)= .86494 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 12 to 19 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 951 944.3 .048 .048 r =5 21751 21743.9 .002 .050 r =6 77298 77311.8 .002 .052 p=1-exp(-SUM/2)= .02581 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 13 to 20 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 970 944.3 .699 .699 r =5 21653 21743.9 .380 1.079 r =6 77377 77311.8 .055 1.134 p=1-exp(-SUM/2)= .43288 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 14 to 21 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 988 944.3 2.022 2.022 r =5 21907 21743.9 1.223 3.246 r =6 77105 77311.8 .553 3.799 p=1-exp(-SUM/2)= .85034 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 15 to 22 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 992 944.3 2.409 2.409 r =5 21637 21743.9 .526 2.935 r =6 77371 77311.8 .045 2.980 p=1-exp(-SUM/2)= .77466 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 16 to 23 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 943 944.3 .002 .002 r =5 21790 21743.9 .098 .100 r =6 77267 77311.8 .026 .125 p=1-exp(-SUM/2)= .06082 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 17 to 24 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 998 944.3 3.054 3.054 r =5 21821 21743.9 .273 3.327 r =6 77181 77311.8 .221 3.548 p=1-exp(-SUM/2)= .83037 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 18 to 25 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 922 944.3 .527 .527 r =5 21709 21743.9 .056 .583 r =6 77369 77311.8 .042 .625 p=1-exp(-SUM/2)= .26839 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 19 to 26 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 915 944.3 .909 .909 r =5 21702 21743.9 .081 .990 r =6 77383 77311.8 .066 1.056 p=1-exp(-SUM/2)= .41007 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 20 to 27 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 867 944.3 6.328 6.328 r =5 21692 21743.9 .124 6.452 r =6 77441 77311.8 .216 6.668 p=1-exp(-SUM/2)= .96434 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 21 to 28 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 886 944.3 3.600 3.600 r =5 21405 21743.9 5.282 8.882 r =6 77709 77311.8 2.041 10.922 p=1-exp(-SUM/2)= .99575 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 22 to 29 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 973 944.3 .872 .872 r =5 21542 21743.9 1.875 2.747 r =6 77485 77311.8 .388 3.135 p=1-exp(-SUM/2)= .79143 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 23 to 30 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 885 944.3 3.724 3.724 r =5 21657 21743.9 .347 4.071 r =6 77458 77311.8 .276 4.348 p=1-exp(-SUM/2)= .88627 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 24 to 31 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 944 944.3 .000 .000 r =5 21729 21743.9 .010 .010 r =6 77327 77311.8 .003 .013 p=1-exp(-SUM/2)= .00662 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG randnumb.bin b-rank test for bits 25 to 32 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 897 944.3 2.369 2.369 r =5 21786 21743.9 .082 2.451 r =6 77317 77311.8 .000 2.451 p=1-exp(-SUM/2)= .70642 TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices These should be 25 uniform [0,1] random variables: .492591 .140335 .552921 .363156 .635619 .848542 .150218 .648319 .483047 .552624 .864940 .025812 .432879 .850342 .774656 .060820 .830375 .268389 .410072 .964345 .995751 .791425 .886268 .006625 .706425 brank test summary for randnumb.bin The KS test for those 25 supposed UNI's yields KS p-value= .459437 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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: 141412 missing words, -1.16 sigmas from mean, p-value= .12262 tst no 2: 142354 missing words, 1.04 sigmas from mean, p-value= .85059 tst no 3: 141909 missing words, .00 sigmas from mean, p-value= .49969 tst no 4: 141589 missing words, -.75 sigmas from mean, p-value= .22710 tst no 5: 141438 missing words, -1.10 sigmas from mean, p-value= .13540 tst no 6: 141510 missing words, -.93 sigmas from mean, p-value= .17541 tst no 7: 141438 missing words, -1.10 sigmas from mean, p-value= .13540 tst no 8: 141480 missing words, -1.00 sigmas from mean, p-value= .15791 tst no 9: 142678 missing words, 1.80 sigmas from mean, p-value= .96375 tst no 10: 142135 missing words, .53 sigmas from mean, p-value= .70100 tst no 11: 141561 missing words, -.81 sigmas from mean, p-value= .20787 tst no 12: 141334 missing words, -1.34 sigmas from mean, p-value= .08944 tst no 13: 141922 missing words, .03 sigmas from mean, p-value= .51181 tst no 14: 142476 missing words, 1.32 sigmas from mean, p-value= .90725 tst no 15: 141778 missing words, -.31 sigmas from mean, p-value= .37948 tst no 16: 142083 missing words, .41 sigmas from mean, p-value= .65755 tst no 17: 141884 missing words, -.06 sigmas from mean, p-value= .47641 tst no 18: 142190 missing words, .66 sigmas from mean, p-value= .74402 tst no 19: 141125 missing words, -1.83 sigmas from mean, p-value= .03344 tst no 20: 142006 missing words, .23 sigmas from mean, p-value= .58935 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 randnumb.bin Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OPSO for randnumb.bin using bits 23 to 32 141998 .306 .6201 OPSO for randnumb.bin using bits 22 to 31 142232 1.113 .8671 OPSO for randnumb.bin using bits 21 to 30 141601 -1.063 .1438 OPSO for randnumb.bin using bits 20 to 29 142159 .861 .8054 OPSO for randnumb.bin using bits 19 to 28 142165 .882 .8110 OPSO for randnumb.bin using bits 18 to 27 141650 -.894 .1856 OPSO for randnumb.bin using bits 17 to 26 141767 -.491 .3118 OPSO for randnumb.bin using bits 16 to 25 141763 -.505 .3069 OPSO for randnumb.bin using bits 15 to 24 141557 -1.215 .1122 OPSO for randnumb.bin using bits 14 to 23 142224 1.085 .8611 OPSO for randnumb.bin using bits 13 to 22 141923 .047 .5188 OPSO for randnumb.bin using bits 12 to 21 142372 1.595 .9447 OPSO for randnumb.bin using bits 11 to 20 141907 -.008 .4968 OPSO for randnumb.bin using bits 10 to 19 141852 -.198 .4216 OPSO for randnumb.bin using bits 9 to 18 141765 -.498 .3094 OPSO for randnumb.bin using bits 8 to 17 141973 .220 .5869 OPSO for randnumb.bin using bits 7 to 16 141697 -.732 .2320 OPSO for randnumb.bin using bits 6 to 15 141857 -.180 .4284 OPSO for randnumb.bin using bits 5 to 14 141846 -.218 .4136 OPSO for randnumb.bin using bits 4 to 13 141933 .082 .5325 OPSO for randnumb.bin using bits 3 to 12 142225 1.089 .8618 OPSO for randnumb.bin using bits 2 to 11 142036 .437 .6689 OPSO for randnumb.bin using bits 1 to 10 141891 -.063 .4748 OQSO test for generator randnumb.bin Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OQSO for randnumb.bin using bits 28 to 32 141782 -.432 .3330 OQSO for randnumb.bin using bits 27 to 31 141610 -1.015 .1551 OQSO for randnumb.bin using bits 26 to 30 142547 2.162 .9847 OQSO for randnumb.bin using bits 25 to 29 141981 .243 .5960 OQSO for randnumb.bin using bits 24 to 28 141848 -.208 .4177 OQSO for randnumb.bin using bits 23 to 27 142007 .331 .6297 OQSO for randnumb.bin using bits 22 to 26 141133 -2.632 .0042 OQSO for randnumb.bin using bits 21 to 25 141911 .006 .5023 OQSO for randnumb.bin using bits 20 to 24 142144 .795 .7868 OQSO for randnumb.bin using bits 19 to 23 141821 -.299 .3823 OQSO for randnumb.bin using bits 18 to 22 141857 -.177 .4296 OQSO for randnumb.bin using bits 17 to 21 141536 -1.266 .1028 OQSO for randnumb.bin using bits 16 to 20 141851 -.198 .4216 OQSO for randnumb.bin using bits 15 to 19 141788 -.411 .3404 OQSO for randnumb.bin using bits 14 to 18 142929 3.457 .9997 OQSO for randnumb.bin using bits 13 to 17 142552 2.179 .9853 OQSO for randnumb.bin using bits 12 to 16 141936 .090 .5360 OQSO for randnumb.bin using bits 11 to 15 141911 .006 .5023 OQSO for randnumb.bin using bits 10 to 14 141818 -.310 .3784 OQSO for randnumb.bin using bits 9 to 13 142204 .999 .8411 OQSO for randnumb.bin using bits 8 to 12 141619 -.984 .1625 OQSO for randnumb.bin using bits 7 to 11 141814 -.323 .3733 OQSO for randnumb.bin using bits 6 to 10 141572 -1.143 .1264 OQSO for randnumb.bin using bits 5 to 9 141585 -1.099 .1358 OQSO for randnumb.bin using bits 4 to 8 141422 -1.652 .0493 OQSO for randnumb.bin using bits 3 to 7 141751 -.537 .2957 OQSO for randnumb.bin using bits 2 to 6 141639 -.916 .1797 OQSO for randnumb.bin using bits 1 to 5 141954 .151 .5602 DNA test for generator randnumb.bin Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p DNA for randnumb.bin using bits 31 to 32 141472 -1.290 .0985 DNA for randnumb.bin using bits 30 to 31 141920 .031 .5126 DNA for randnumb.bin using bits 29 to 30 142745 2.465 .9932 DNA for randnumb.bin using bits 28 to 29 141981 .211 .5837 DNA for randnumb.bin using bits 27 to 28 141746 -.482 .3150 DNA for randnumb.bin using bits 26 to 27 142096 .551 .7091 DNA for randnumb.bin using bits 25 to 26 142100 .562 .7131 DNA for randnumb.bin using bits 24 to 25 142493 1.722 .9574 DNA for randnumb.bin using bits 23 to 24 142016 .315 .6235 DNA for randnumb.bin using bits 22 to 23 141612 -.877 .1902 DNA for randnumb.bin using bits 21 to 22 141745 -.485 .3139 DNA for randnumb.bin using bits 20 to 21 141987 .229 .5906 DNA for randnumb.bin using bits 19 to 20 142099 .560 .7121 DNA for randnumb.bin using bits 18 to 19 141648 -.771 .2204 DNA for randnumb.bin using bits 17 to 18 142195 .843 .8003 DNA for randnumb.bin using bits 16 to 17 141744 -.488 .3129 DNA for randnumb.bin using bits 15 to 16 141603 -.904 .1831 DNA for randnumb.bin using bits 14 to 15 141424 -1.432 .0761 DNA for randnumb.bin using bits 13 to 14 141678 -.682 .2475 DNA for randnumb.bin using bits 12 to 13 141792 -.346 .3646 DNA for randnumb.bin using bits 11 to 12 141646 -.777 .2186 DNA for randnumb.bin using bits 10 to 11 141688 -.653 .2569 DNA for randnumb.bin using bits 9 to 10 142468 1.648 .9503 DNA for randnumb.bin using bits 8 to 9 142016 .315 .6235 DNA for randnumb.bin using bits 7 to 8 141601 -.910 .1815 DNA for randnumb.bin using bits 6 to 7 141237 -1.983 .0237 DNA for randnumb.bin using bits 5 to 6 142091 .536 .7040 DNA for randnumb.bin using bits 4 to 5 141850 -.175 .4305 DNA for randnumb.bin using bits 3 to 4 141629 -.827 .2041 DNA for randnumb.bin using bits 2 to 3 141949 .117 .5466 DNA for randnumb.bin using bits 1 to 2 142218 .911 .8187 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 randnumb.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 randnumb.bin 2371.67 -1.815 .034771 byte stream for randnumb.bin 2413.29 -1.226 .110043 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 2519.83 .280 .610413 bits 2 to 9 2489.38 -.150 .440286 bits 3 to 10 2581.08 1.147 .874250 bits 4 to 11 2462.92 -.524 .299979 bits 5 to 12 2417.83 -1.162 .122604 bits 6 to 13 2579.16 1.120 .868545 bits 7 to 14 2502.24 .032 .512628 bits 8 to 15 2662.51 2.298 .989226 bits 9 to 16 2509.47 .134 .553270 bits 10 to 17 2432.21 -.959 .168868 bits 11 to 18 2510.99 .155 .561769 bits 12 to 19 2454.21 -.648 .258610 bits 13 to 20 2608.03 1.528 .936716 bits 14 to 21 2563.60 .899 .815773 bits 15 to 22 2741.69 3.418 .999685 bits 16 to 23 2438.42 -.871 .191903 bits 17 to 24 2367.26 -1.877 .030241 bits 18 to 25 2527.15 .384 .649521 bits 19 to 26 2498.48 -.021 .491447 bits 20 to 27 2457.90 -.595 .275806 bits 21 to 28 2620.42 1.703 .955717 bits 22 to 29 2528.26 .400 .655291 bits 23 to 30 2564.16 .907 .817905 bits 24 to 31 2429.51 -.997 .159428 bits 25 to 32 2530.61 .433 .667430 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 randnumb.bin Of 12,000 tries, the average no. of successes should be 3523 with sigma=21.9 Successes: 3538 z-score: .685 p-value: .753306 Successes: 3505 z-score: -.822 p-value: .205562 Successes: 3513 z-score: -.457 p-value: .323972 Successes: 3552 z-score: 1.324 p-value: .907282 Successes: 3509 z-score: -.639 p-value: .261324 Successes: 3469 z-score: -2.466 p-value: .006836 Successes: 3546 z-score: 1.050 p-value: .853193 Successes: 3531 z-score: .365 p-value: .642555 Successes: 3510 z-score: -.594 p-value: .276387 Successes: 3524 z-score: .046 p-value: .518210 square size avg. no. parked sample sigma 100. 3519.700 22.941 KSTEST for the above 10: p= .091924 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 randnumb.bin Sample no. d^2 avg equiv uni 5 .5575 .4936 .428989 10 .0982 .4890 .093972 15 2.8059 .7301 .940394 20 .8751 .8043 .585021 25 .6628 .8831 .486306 30 .4041 .8970 .333799 35 .5323 .8210 .414336 40 .8739 .8740 .584496 45 .2143 .9049 .193731 50 .4907 .9249 .389336 55 1.2359 .9317 .711227 60 2.5904 .9588 .925977 65 7.6317 1.0568 .999533 70 .5043 1.0289 .397575 75 1.0447 1.0462 .650043 80 1.4299 1.0459 .762374 85 1.8449 1.0388 .843414 90 .3415 1.0854 .290529 95 .9326 1.0674 .608298 100 1.6345 1.0936 .806540 MINIMUM DISTANCE TEST for randnumb.bin Result of KS test on 20 transformed mindist^2's: p-value= .690770 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 randnumb.bin sample no: 1 r^3= .201 p-value= .00667 sample no: 2 r^3= 20.612 p-value= .49696 sample no: 3 r^3= 124.067 p-value= .98401 sample no: 4 r^3= 8.522 p-value= .24728 sample no: 5 r^3= 146.586 p-value= .99245 sample no: 6 r^3= 2.232 p-value= .07170 sample no: 7 r^3= 49.146 p-value= .80567 sample no: 8 r^3= 23.011 p-value= .53561 sample no: 9 r^3= 16.711 p-value= .42710 sample no: 10 r^3= 24.414 p-value= .55683 sample no: 11 r^3= 105.242 p-value= .97005 sample no: 12 r^3= 66.854 p-value= .89231 sample no: 13 r^3= 2.450 p-value= .07843 sample no: 14 r^3= 37.286 p-value= .71144 sample no: 15 r^3= 23.210 p-value= .53868 sample no: 16 r^3= 25.761 p-value= .57628 sample no: 17 r^3= 26.929 p-value= .59247 sample no: 18 r^3= 57.709 p-value= .85392 sample no: 19 r^3= 22.318 p-value= .52476 sample no: 20 r^3= 32.503 p-value= .66157 A KS test is applied to those 20 p-values. --------------------------------------------------------- 3DSPHERES test for file randnumb.bin p-value= .775862 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 randnumb.bin Table of standardized frequency counts ( (obs-exp)/sqrt(exp) )^2 for j taking values <=6,7,8,...,47,>=48: 3.4 .1 -.6 1.6 -.5 .9 -.5 1.7 .2 -.5 -.9 -1.1 .4 -.3 1.3 -1.1 1.3 -.7 .9 -.5 -.1 -.8 1.7 -.3 -.6 -1.3 1.7 -.5 -.1 -1.5 .7 -.3 -1.5 .0 .2 2.0 -.7 1.1 .9 -.1 1.6 .0 -.1 Chi-square with 42 degrees of freedom: 51.169 z-score= 1.000 p-value= .843286 ______________________________________________________________ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 .687281 Test no. 2 p-value .239832 Test no. 3 p-value .780777 Test no. 4 p-value .686973 Test no. 5 p-value .658549 Test no. 6 p-value .914380 Test no. 7 p-value .266535 Test no. 8 p-value .836885 Test no. 9 p-value .603915 Test no. 10 p-value .289208 Results of the OSUM test for randnumb.bin KSTEST on the above 10 p-values: .635848 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 randnumb.bin Up and down runs in a sample of 10000 _________________________________________________ Run test for randnumb.bin : runs up; ks test for 10 p's: .698717 runs down; ks test for 10 p's: .628001 Run test for randnumb.bin : runs up; ks test for 10 p's: .304695 runs down; ks test for 10 p's: .254565 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 randnumb.bin No. of wins: Observed Expected 98220 98585.86 98220= No. of wins, z-score=-1.636 pvalue= .05088 Analysis of Throws-per-Game: Chisq= 12.87 for 20 degrees of freedom, p= .11695 Throws Observed Expected Chisq Sum 1 66836 66666.7 .430 .430 2 37379 37654.3 2.013 2.443 3 26858 26954.7 .347 2.790 4 19275 19313.5 .077 2.867 5 13876 13851.4 .044 2.911 6 10040 9943.5 .936 3.846 7 7234 7145.0 1.108 4.954 8 5115 5139.1 .113 5.067 9 3701 3699.9 .000 5.067 10 2626 2666.3 .609 5.676 11 1915 1923.3 .036 5.712 12 1430 1388.7 1.226 6.938 13 1023 1003.7 .371 7.309 14 758 726.1 1.398 8.707 15 516 525.8 .184 8.891 16 390 381.2 .205 9.096 17 285 276.5 .259 9.355 18 183 200.8 1.583 10.938 19 147 146.0 .007 10.945 20 103 106.2 .097 11.042 21 310 287.1 1.824 12.866 SUMMARY FOR randnumb.bin p-value for no. of wins: .050885 p-value for throws/game: .116953 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Results of DIEHARD battery of tests sent to file diehard.out