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 otp00000.bin For a sample of size 500: mean otp00000.bin using bits 1 to 24 1.942 duplicate number number spacings observed expected 0 82. 67.668 1 126. 135.335 2 136. 135.335 3 87. 90.224 4 45. 45.112 5 15. 18.045 6 to INF 9. 8.282 Chisquare with 6 d.o.f. = 4.37 p-value= .373843 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean otp00000.bin using bits 2 to 25 2.060 duplicate number number spacings observed expected 0 77. 67.668 1 122. 135.335 2 123. 135.335 3 99. 90.224 4 45. 45.112 5 23. 18.045 6 to INF 11. 8.282 Chisquare with 6 d.o.f. = 6.83 p-value= .663366 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean otp00000.bin using bits 3 to 26 2.060 duplicate number number spacings observed expected 0 61. 67.668 1 139. 135.335 2 137. 135.335 3 85. 90.224 4 44. 45.112 5 24. 18.045 6 to INF 10. 8.282 Chisquare with 6 d.o.f. = 3.43 p-value= .246532 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean otp00000.bin using bits 4 to 27 1.990 duplicate number number spacings observed expected 0 68. 67.668 1 155. 135.335 2 112. 135.335 3 88. 90.224 4 46. 45.112 5 22. 18.045 6 to INF 9. 8.282 Chisquare with 6 d.o.f. = 7.88 p-value= .753285 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean otp00000.bin using bits 5 to 28 1.928 duplicate number number spacings observed expected 0 73. 67.668 1 147. 135.335 2 120. 135.335 3 92. 90.224 4 50. 45.112 5 8. 18.045 6 to INF 10. 8.282 Chisquare with 6 d.o.f. = 9.68 p-value= .861018 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean otp00000.bin using bits 6 to 29 2.072 duplicate number number spacings observed expected 0 59. 67.668 1 118. 135.335 2 163. 135.335 3 87. 90.224 4 47. 45.112 5 14. 18.045 6 to INF 12. 8.282 Chisquare with 6 d.o.f. = 11.76 p-value= .932361 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean otp00000.bin using bits 7 to 30 2.078 duplicate number number spacings observed expected 0 65. 67.668 1 123. 135.335 2 137. 135.335 3 95. 90.224 4 53. 45.112 5 19. 18.045 6 to INF 8. 8.282 Chisquare with 6 d.o.f. = 2.94 p-value= .183950 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean otp00000.bin using bits 8 to 31 2.118 duplicate number number spacings observed expected 0 57. 67.668 1 121. 135.335 2 156. 135.335 3 85. 90.224 4 50. 45.112 5 20. 18.045 6 to INF 11. 8.282 Chisquare with 6 d.o.f. = 8.29 p-value= .782495 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean otp00000.bin using bits 9 to 32 1.924 duplicate number number spacings observed expected 0 67. 67.668 1 136. 135.335 2 155. 135.335 3 78. 90.224 4 45. 45.112 5 14. 18.045 6 to INF 5. 8.282 Chisquare with 6 d.o.f. = 6.73 p-value= .653521 ::::::::::::::::::::::::::::::::::::::::: The 9 p-values were .373843 .663366 .246532 .753285 .861018 .932361 .183950 .782495 .653521 A KSTEST for the 9 p-values yields .543178 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 otp00000.bin For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom= 72.793; p-value= .022276 OPERM5 test for file otp00000.bin For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom= 81.191; p-value= .096333 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 otp00000.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 189 211.4 2.377126 2.377 29 5169 5134.0 .238465 2.616 30 23048 23103.0 .131158 2.747 31 11594 11551.5 .156185 2.903 chisquare= 2.903 for 3 d. of f.; p-value= .637375 -------------------------------------------------------------- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 otp00000.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 190 211.4 2.169784 2.170 30 5093 5134.0 .327588 2.497 31 23170 23103.0 .194032 2.691 32 11547 11551.5 .001772 2.693 chisquare= 2.693 for 3 d. of f.; p-value= .609001 -------------------------------------------------------------- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 otp00000.bin Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 1 to 8 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 956 944.3 .145 .145 r =5 21642 21743.9 .478 .622 r =6 77402 77311.8 .105 .728 p=1-exp(-SUM/2)= .30501 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 2 to 9 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 930 944.3 .217 .217 r =5 21728 21743.9 .012 .228 r =6 77342 77311.8 .012 .240 p=1-exp(-SUM/2)= .11308 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 3 to 10 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 905 944.3 1.636 1.636 r =5 21683 21743.9 .171 1.806 r =6 77412 77311.8 .130 1.936 p=1-exp(-SUM/2)= .62018 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 4 to 11 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 928 944.3 .281 .281 r =5 21617 21743.9 .741 1.022 r =6 77455 77311.8 .265 1.287 p=1-exp(-SUM/2)= .47461 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 5 to 12 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 928 944.3 .281 .281 r =5 21704 21743.9 .073 .355 r =6 77368 77311.8 .041 .395 p=1-exp(-SUM/2)= .17941 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 6 to 13 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 961 944.3 .295 .295 r =5 21783 21743.9 .070 .366 r =6 77256 77311.8 .040 .406 p=1-exp(-SUM/2)= .18367 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 7 to 14 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 905 944.3 1.636 1.636 r =5 21434 21743.9 4.417 6.052 r =6 77661 77311.8 1.577 7.630 p=1-exp(-SUM/2)= .97796 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 8 to 15 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 904 944.3 1.720 1.720 r =5 21585 21743.9 1.161 2.881 r =6 77511 77311.8 .513 3.394 p=1-exp(-SUM/2)= .81681 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 9 to 16 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 900 944.3 2.078 2.078 r =5 21722 21743.9 .022 2.100 r =6 77378 77311.8 .057 2.157 p=1-exp(-SUM/2)= .65991 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.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 21797 21743.9 .130 1.765 r =6 77298 77311.8 .002 1.768 p=1-exp(-SUM/2)= .58684 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 11 to 18 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 920 944.3 .625 .625 r =5 21775 21743.9 .044 .670 r =6 77305 77311.8 .001 .670 p=1-exp(-SUM/2)= .28483 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.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 21568 21743.9 1.423 1.470 r =6 77481 77311.8 .370 1.841 p=1-exp(-SUM/2)= .60163 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 13 to 20 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 960 944.3 .261 .261 r =5 21808 21743.9 .189 .450 r =6 77232 77311.8 .082 .532 p=1-exp(-SUM/2)= .23369 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 14 to 21 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 928 944.3 .281 .281 r =5 21734 21743.9 .005 .286 r =6 77338 77311.8 .009 .295 p=1-exp(-SUM/2)= .13705 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 15 to 22 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 1009 944.3 4.433 4.433 r =5 21971 21743.9 2.372 6.805 r =6 77020 77311.8 1.101 7.906 p=1-exp(-SUM/2)= .98080 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 16 to 23 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 995 944.3 2.722 2.722 r =5 21929 21743.9 1.576 4.298 r =6 77076 77311.8 .719 5.017 p=1-exp(-SUM/2)= .91861 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 17 to 24 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 985 944.3 1.754 1.754 r =5 21886 21743.9 .929 2.683 r =6 77129 77311.8 .432 3.115 p=1-exp(-SUM/2)= .78934 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 18 to 25 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 966 944.3 .499 .499 r =5 21715 21743.9 .038 .537 r =6 77319 77311.8 .001 .538 p=1-exp(-SUM/2)= .23574 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 19 to 26 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 929 944.3 .248 .248 r =5 21808 21743.9 .189 .437 r =6 77263 77311.8 .031 .468 p=1-exp(-SUM/2)= .20852 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 20 to 27 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 943 944.3 .002 .002 r =5 21732 21743.9 .007 .008 r =6 77325 77311.8 .002 .011 p=1-exp(-SUM/2)= .00527 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 21 to 28 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 965 944.3 .454 .454 r =5 21562 21743.9 1.522 1.975 r =6 77473 77311.8 .336 2.312 p=1-exp(-SUM/2)= .68518 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 22 to 29 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 868 944.3 6.165 6.165 r =5 21737 21743.9 .002 6.167 r =6 77395 77311.8 .090 6.257 p=1-exp(-SUM/2)= .95622 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.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 21402 21743.9 5.376 5.657 r =6 77670 77311.8 1.660 7.317 p=1-exp(-SUM/2)= .97423 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 24 to 31 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 928 944.3 .281 .281 r =5 22014 21743.9 3.355 3.637 r =6 77058 77311.8 .833 4.470 p=1-exp(-SUM/2)= .89299 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG otp00000.bin b-rank test for bits 25 to 32 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 939 944.3 .030 .030 r =5 21849 21743.9 .508 .538 r =6 77212 77311.8 .129 .667 p=1-exp(-SUM/2)= .28345 TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices These should be 25 uniform [0,1] random variables: .305006 .113084 .620180 .474612 .179413 .183674 .977959 .816808 .659912 .586838 .284828 .601635 .233686 .137046 .980804 .918605 .789335 .235738 .208523 .005265 .685179 .956217 .974229 .892995 .283446 brank test summary for otp00000.bin The KS test for those 25 supposed UNI's yields KS p-value= .602130 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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: 141500 missing words, -.96 sigmas from mean, p-value= .16944 tst no 2: 141528 missing words, -.89 sigmas from mean, p-value= .18648 tst no 3: 142226 missing words, .74 sigmas from mean, p-value= .77032 tst no 4: 142194 missing words, .67 sigmas from mean, p-value= .74701 tst no 5: 141800 missing words, -.26 sigmas from mean, p-value= .39919 tst no 6: 141337 missing words, -1.34 sigmas from mean, p-value= .09058 tst no 7: 142271 missing words, .85 sigmas from mean, p-value= .80095 tst no 8: 141750 missing words, -.37 sigmas from mean, p-value= .35485 tst no 9: 142038 missing words, .30 sigmas from mean, p-value= .61815 tst no 10: 141663 missing words, -.58 sigmas from mean, p-value= .28247 tst no 11: 141305 missing words, -1.41 sigmas from mean, p-value= .07898 tst no 12: 141888 missing words, -.05 sigmas from mean, p-value= .48013 tst no 13: 141519 missing words, -.91 sigmas from mean, p-value= .18089 tst no 14: 141865 missing words, -.10 sigmas from mean, p-value= .45876 tst no 15: 142746 missing words, 1.95 sigmas from mean, p-value= .97470 tst no 16: 142315 missing words, .95 sigmas from mean, p-value= .82839 tst no 17: 140897 missing words, -2.37 sigmas from mean, p-value= .00901 tst no 18: 142022 missing words, .26 sigmas from mean, p-value= .60382 tst no 19: 142634 missing words, 1.69 sigmas from mean, p-value= .95479 tst no 20: 141697 missing words, -.50 sigmas from mean, p-value= .30991 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 otp00000.bin Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OPSO for otp00000.bin using bits 23 to 32 142301 1.351 .9116 OPSO for otp00000.bin using bits 22 to 31 141414 -1.708 .0438 OPSO for otp00000.bin using bits 21 to 30 141759 -.518 .3021 OPSO for otp00000.bin using bits 20 to 29 141845 -.222 .4122 OPSO for otp00000.bin using bits 19 to 28 142074 .568 .7149 OPSO for otp00000.bin using bits 18 to 27 142204 1.016 .8452 OPSO for otp00000.bin using bits 17 to 26 141788 -.418 .3378 OPSO for otp00000.bin using bits 16 to 25 142066 .540 .7055 OPSO for otp00000.bin using bits 15 to 24 142072 .561 .7126 OPSO for otp00000.bin using bits 14 to 23 142357 1.544 .9387 OPSO for otp00000.bin using bits 13 to 22 141856 -.184 .4270 OPSO for otp00000.bin using bits 12 to 21 141487 -1.456 .0727 OPSO for otp00000.bin using bits 11 to 20 141972 .216 .5855 OPSO for otp00000.bin using bits 10 to 19 141341 -1.960 .0250 OPSO for otp00000.bin using bits 9 to 18 142314 1.395 .9186 OPSO for otp00000.bin using bits 8 to 17 142087 .613 .7299 OPSO for otp00000.bin using bits 7 to 16 142089 .620 .7322 OPSO for otp00000.bin using bits 6 to 15 141599 -1.070 .1423 OPSO for otp00000.bin using bits 5 to 14 141741 -.580 .2808 OPSO for otp00000.bin using bits 4 to 13 141939 .102 .5407 OPSO for otp00000.bin using bits 3 to 12 141606 -1.046 .1478 OPSO for otp00000.bin using bits 2 to 11 141590 -1.101 .1354 OPSO for otp00000.bin using bits 1 to 10 142309 1.378 .9159 OQSO test for generator otp00000.bin Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OQSO for otp00000.bin using bits 28 to 32 141941 .107 .5427 OQSO for otp00000.bin using bits 27 to 31 141538 -1.259 .1041 OQSO for otp00000.bin using bits 26 to 30 141807 -.347 .3643 OQSO for otp00000.bin using bits 25 to 29 142099 .643 .7399 OQSO for otp00000.bin using bits 24 to 28 141534 -1.272 .1016 OQSO for otp00000.bin using bits 23 to 27 142222 1.060 .8554 OQSO for otp00000.bin using bits 22 to 26 142015 .358 .6399 OQSO for otp00000.bin using bits 21 to 25 141560 -1.184 .1182 OQSO for otp00000.bin using bits 20 to 24 141632 -.940 .1736 OQSO for otp00000.bin using bits 19 to 23 141900 -.032 .4874 OQSO for otp00000.bin using bits 18 to 22 141500 -1.388 .0826 OQSO for otp00000.bin using bits 17 to 21 142065 .528 .7011 OQSO for otp00000.bin using bits 16 to 20 142172 .890 .8134 OQSO for otp00000.bin using bits 15 to 19 141362 -1.855 .0318 OQSO for otp00000.bin using bits 14 to 18 141970 .206 .5815 OQSO for otp00000.bin using bits 13 to 17 141785 -.421 .3367 OQSO for otp00000.bin using bits 12 to 16 142023 .385 .6500 OQSO for otp00000.bin using bits 11 to 15 141930 .070 .5279 OQSO for otp00000.bin using bits 10 to 14 142199 .982 .8369 OQSO for otp00000.bin using bits 9 to 13 142027 .399 .6550 OQSO for otp00000.bin using bits 8 to 12 142321 1.395 .9186 OQSO for otp00000.bin using bits 7 to 11 142096 .633 .7366 OQSO for otp00000.bin using bits 6 to 10 141875 -.116 .4537 OQSO for otp00000.bin using bits 5 to 9 141567 -1.160 .1229 OQSO for otp00000.bin using bits 4 to 8 142002 .314 .6233 OQSO for otp00000.bin using bits 3 to 7 141715 -.659 .2550 OQSO for otp00000.bin using bits 2 to 6 141904 -.018 .4928 OQSO for otp00000.bin using bits 1 to 5 141435 -1.608 .0539 DNA test for generator otp00000.bin Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p DNA for otp00000.bin using bits 31 to 32 142098 .557 .7111 DNA for otp00000.bin using bits 30 to 31 141947 .111 .5442 DNA for otp00000.bin using bits 29 to 30 141233 -1.995 .0230 DNA for otp00000.bin using bits 28 to 29 142316 1.200 .8849 DNA for otp00000.bin using bits 27 to 28 141339 -1.682 .0462 DNA for otp00000.bin using bits 26 to 27 141929 .058 .5231 DNA for otp00000.bin using bits 25 to 26 142365 1.344 .9106 DNA for otp00000.bin using bits 24 to 25 141580 -.971 .1657 DNA for otp00000.bin using bits 23 to 24 141969 .176 .5699 DNA for otp00000.bin using bits 22 to 23 141875 -.101 .4597 DNA for otp00000.bin using bits 21 to 22 141273 -1.877 .0303 DNA for otp00000.bin using bits 20 to 21 142198 .852 .8028 DNA for otp00000.bin using bits 19 to 20 141889 -.060 .4761 DNA for otp00000.bin using bits 18 to 19 140906 -2.960 .0015 DNA for otp00000.bin using bits 17 to 18 142624 2.108 .9825 DNA for otp00000.bin using bits 16 to 17 141708 -.594 .2763 DNA for otp00000.bin using bits 15 to 16 141979 .206 .5814 DNA for otp00000.bin using bits 14 to 15 142129 .648 .7415 DNA for otp00000.bin using bits 13 to 14 142101 .565 .7141 DNA for otp00000.bin using bits 12 to 13 142192 .834 .7978 DNA for otp00000.bin using bits 11 to 12 142011 .300 .6179 DNA for otp00000.bin using bits 10 to 11 142447 1.586 .9436 DNA for otp00000.bin using bits 9 to 10 142546 1.878 .9698 DNA for otp00000.bin using bits 8 to 9 141405 -1.488 .0684 DNA for otp00000.bin using bits 7 to 8 141550 -1.060 .1446 DNA for otp00000.bin using bits 6 to 7 141718 -.564 .2862 DNA for otp00000.bin using bits 5 to 6 141997 .259 .6020 DNA for otp00000.bin using bits 4 to 5 141884 -.075 .4702 DNA for otp00000.bin using bits 3 to 4 141392 -1.526 .0635 DNA for otp00000.bin using bits 2 to 3 142335 1.256 .8954 DNA for otp00000.bin using bits 1 to 2 142412 1.483 .9309 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 otp00000.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 otp00000.bin 2433.76 -.937 .174426 byte stream for otp00000.bin 2560.82 .860 .805144 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 2394.17 -1.497 .067236 bits 2 to 9 2561.32 .867 .807099 bits 3 to 10 2498.00 -.028 .488742 bits 4 to 11 2493.13 -.097 .461308 bits 5 to 12 2484.81 -.215 .414957 bits 6 to 13 2617.10 1.656 .951138 bits 7 to 14 2614.09 1.613 .946681 bits 8 to 15 2493.33 -.094 .462414 bits 9 to 16 2532.16 .455 .675361 bits 10 to 17 2434.88 -.921 .178548 bits 11 to 18 2585.70 1.212 .887237 bits 12 to 19 2548.02 .679 .751487 bits 13 to 20 2424.72 -1.065 .143540 bits 14 to 21 2606.20 1.502 .933434 bits 15 to 22 2549.29 .697 .757124 bits 16 to 23 2464.93 -.496 .309962 bits 17 to 24 2535.88 .507 .694048 bits 18 to 25 2445.65 -.769 .221045 bits 19 to 26 2419.98 -1.132 .128904 bits 20 to 27 2477.13 -.323 .373178 bits 21 to 28 2445.36 -.773 .219825 bits 22 to 29 2433.80 -.936 .174571 bits 23 to 30 2454.34 -.646 .259219 bits 24 to 31 2505.65 .080 .531822 bits 25 to 32 2537.36 .528 .701393 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 otp00000.bin Of 12,000 tries, the average no. of successes should be 3523 with sigma=21.9 Successes: 3516 z-score: -.320 p-value: .374623 Successes: 3535 z-score: .548 p-value: .708135 Successes: 3511 z-score: -.548 p-value: .291865 Successes: 3519 z-score: -.183 p-value: .427537 Successes: 3518 z-score: -.228 p-value: .409702 Successes: 3530 z-score: .320 p-value: .625377 Successes: 3532 z-score: .411 p-value: .659449 Successes: 3516 z-score: -.320 p-value: .374623 Successes: 3546 z-score: 1.050 p-value: .853193 Successes: 3550 z-score: 1.233 p-value: .891189 square size avg. no. parked sample sigma 100. 3527.300 12.756 KSTEST for the above 10: p= .566597 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 otp00000.bin Sample no. d^2 avg equiv uni 5 .8495 .5886 .574201 10 .5786 .9410 .440919 15 .1663 .9108 .153893 20 .3969 .8740 .328937 25 .7138 .8861 .511991 30 .4816 .8941 .383676 35 .0421 .8575 .041472 40 .6001 .8645 .452902 45 1.9246 .8966 .855467 50 1.8462 .9310 .843626 55 3.0385 .9630 .952821 60 2.0369 .9947 .870892 65 1.1978 .9928 .699953 70 .0972 1.0086 .093069 75 1.2528 1.0213 .716091 80 .4810 .9934 .383332 85 .1889 1.0090 .172896 90 .1119 1.0169 .106338 95 4.0565 1.0367 .983040 100 1.3340 1.0515 .738336 MINIMUM DISTANCE TEST for otp00000.bin Result of KS test on 20 transformed mindist^2's: p-value= .859497 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 otp00000.bin sample no: 1 r^3= 125.129 p-value= .98456 sample no: 2 r^3= 94.936 p-value= .95777 sample no: 3 r^3= 9.435 p-value= .26984 sample no: 4 r^3= 12.648 p-value= .34399 sample no: 5 r^3= 24.367 p-value= .55614 sample no: 6 r^3= 47.856 p-value= .79713 sample no: 7 r^3= 86.298 p-value= .94367 sample no: 8 r^3= 58.851 p-value= .85938 sample no: 9 r^3= 41.536 p-value= .74956 sample no: 10 r^3= 3.130 p-value= .09909 sample no: 11 r^3= 93.711 p-value= .95601 sample no: 12 r^3= 10.690 p-value= .29977 sample no: 13 r^3= 15.010 p-value= .39367 sample no: 14 r^3= 37.066 p-value= .70932 sample no: 15 r^3= 129.677 p-value= .98673 sample no: 16 r^3= 15.950 p-value= .41237 sample no: 17 r^3= 48.727 p-value= .80294 sample no: 18 r^3= 8.020 p-value= .23457 sample no: 19 r^3= 3.875 p-value= .12116 sample no: 20 r^3= 48.522 p-value= .80158 A KS test is applied to those 20 p-values. --------------------------------------------------------- 3DSPHERES test for file otp00000.bin p-value= .939197 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 otp00000.bin Table of standardized frequency counts ( (obs-exp)/sqrt(exp) )^2 for j taking values <=6,7,8,...,47,>=48: -1.5 1.3 -.1 .9 1.2 1.5 .1 .2 .0 -.2 -1.6 -1.3 -.6 -1.4 .7 .1 -.4 1.2 .1 .0 .3 1.2 .0 -.2 .9 -.5 .8 .4 .9 -1.1 -1.5 1.0 -.9 .3 -1.3 .6 -.9 .5 .5 2.1 .1 1.0 .8 Chi-square with 42 degrees of freedom: 35.823 z-score= -.674 p-value= .261968 ______________________________________________________________ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 .710709 Test no. 2 p-value .309947 Test no. 3 p-value .133209 Test no. 4 p-value .319272 Test no. 5 p-value .939437 Test no. 6 p-value .496845 Test no. 7 p-value .623042 Test no. 8 p-value .587767 Test no. 9 p-value .889930 Test no. 10 p-value .489005 Results of the OSUM test for otp00000.bin KSTEST on the above 10 p-values: .185118 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 otp00000.bin Up and down runs in a sample of 10000 _________________________________________________ Run test for otp00000.bin : runs up; ks test for 10 p's: .793169 runs down; ks test for 10 p's: .971207 Run test for otp00000.bin : runs up; ks test for 10 p's: .580971 runs down; ks test for 10 p's: .842325 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 otp00000.bin No. of wins: Observed Expected 98577 98585.86 98577= No. of wins, z-score= -.040 pvalue= .48420 Analysis of Throws-per-Game: Chisq= 15.13 for 20 degrees of freedom, p= .23137 Throws Observed Expected Chisq Sum 1 66904 66666.7 .845 .845 2 37560 37654.3 .236 1.081 3 26850 26954.7 .407 1.488 4 19400 19313.5 .388 1.876 5 13628 13851.4 3.604 5.480 6 9886 9943.5 .333 5.812 7 7267 7145.0 2.082 7.895 8 5143 5139.1 .003 7.898 9 3702 3699.9 .001 7.899 10 2657 2666.3 .032 7.931 11 1956 1923.3 .555 8.486 12 1430 1388.7 1.226 9.712 13 1017 1003.7 .176 9.888 14 708 726.1 .453 10.341 15 486 525.8 3.018 13.359 16 380 381.2 .003 13.363 17 284 276.5 .201 13.564 18 207 200.8 .190 13.753 19 156 146.0 .687 14.441 20 106 106.2 .000 14.441 21 273 287.1 .694 15.135 SUMMARY FOR otp00000.bin p-value for no. of wins: .484196 p-value for throws/game: .231368 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Results of DIEHARD battery of tests sent to file res.txt