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 bits.01 For a sample of size 500: mean bits.01 using bits 1 to 24 1.994 duplicate number number spacings observed expected 0 65. 67.668 1 140. 135.335 2 136. 135.335 3 89. 90.224 4 46. 45.112 5 16. 18.045 6 to INF 8. 8.282 Chisquare with 6 d.o.f. = .54 p-value= .002747 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bits.01 using bits 2 to 25 1.954 duplicate number number spacings observed expected 0 68. 67.668 1 145. 135.335 2 136. 135.335 3 80. 90.224 4 46. 45.112 5 16. 18.045 6 to INF 9. 8.282 Chisquare with 6 d.o.f. = 2.17 p-value= .096086 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bits.01 using bits 3 to 26 1.924 duplicate number number spacings observed expected 0 57. 67.668 1 160. 135.335 2 142. 135.335 3 78. 90.224 4 42. 45.112 5 14. 18.045 6 to INF 7. 8.282 Chisquare with 6 d.o.f. = 9.48 p-value= .851709 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bits.01 using bits 4 to 27 1.954 duplicate number number spacings observed expected 0 66. 67.668 1 142. 135.335 2 141. 135.335 3 94. 90.224 4 28. 45.112 5 17. 18.045 6 to INF 12. 8.282 Chisquare with 6 d.o.f. = 8.99 p-value= .825583 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bits.01 using bits 5 to 28 1.948 duplicate number number spacings observed expected 0 81. 67.668 1 142. 135.335 2 117. 135.335 3 81. 90.224 4 52. 45.112 5 17. 18.045 6 to INF 10. 8.282 Chisquare with 6 d.o.f. = 7.85 p-value= .750759 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bits.01 using bits 6 to 29 1.978 duplicate number number spacings observed expected 0 69. 67.668 1 126. 135.335 2 145. 135.335 3 94. 90.224 4 47. 45.112 5 12. 18.045 6 to INF 7. 8.282 Chisquare with 6 d.o.f. = 3.82 p-value= .299080 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bits.01 using bits 7 to 30 2.062 duplicate number number spacings observed expected 0 67. 67.668 1 124. 135.335 2 145. 135.335 3 81. 90.224 4 55. 45.112 5 18. 18.045 6 to INF 10. 8.282 Chisquare with 6 d.o.f. = 5.11 p-value= .470612 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bits.01 using bits 8 to 31 1.904 duplicate number number spacings observed expected 0 74. 67.668 1 141. 135.335 2 133. 135.335 3 92. 90.224 4 40. 45.112 5 11. 18.045 6 to INF 9. 8.282 Chisquare with 6 d.o.f. = 4.30 p-value= .363414 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bits.01 using bits 9 to 32 1.994 duplicate number number spacings observed expected 0 66. 67.668 1 142. 135.335 2 136. 135.335 3 84. 90.224 4 45. 45.112 5 14. 18.045 6 to INF 13. 8.282 Chisquare with 6 d.o.f. = 4.40 p-value= .376849 ::::::::::::::::::::::::::::::::::::::::: The 9 p-values were .002747 .096086 .851709 .825583 .750759 .299080 .470612 .363414 .376849 A KSTEST for the 9 p-values yields .352364 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bits.01 For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom=124.157; p-value= .955629 OPERM5 test for file bits.01 For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom= 95.935; p-value= .431434 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bits.01 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 198 211.4 .851598 .852 29 5256 5134.0 2.898611 3.750 30 22957 23103.0 .923241 4.673 31 11589 11551.5 .121579 4.795 chisquare= 4.795 for 3 d. of f.; p-value= .826835 -------------------------------------------------------------- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bits.01 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 5201 5134.0 .874098 1.857 31 23092 23103.0 .005282 1.863 32 11510 11551.5 .149268 2.012 chisquare= 2.012 for 3 d. of f.; p-value= .508096 -------------------------------------------------------------- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bits.01 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 1 to 8 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 942 944.3 .006 .006 r =5 21655 21743.9 .363 .369 r =6 77403 77311.8 .108 .477 p=1-exp(-SUM/2)= .21205 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 2 to 9 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 966 944.3 .499 .499 r =5 21876 21743.9 .803 1.301 r =6 77158 77311.8 .306 1.607 p=1-exp(-SUM/2)= .55227 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 3 to 10 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 954 944.3 .100 .100 r =5 21595 21743.9 1.020 1.119 r =6 77451 77311.8 .251 1.370 p=1-exp(-SUM/2)= .49588 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 4 to 11 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 935 944.3 .092 .092 r =5 21640 21743.9 .496 .588 r =6 77425 77311.8 .166 .754 p=1-exp(-SUM/2)= .31402 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 5 to 12 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 859 944.3 7.705 7.705 r =5 21732 21743.9 .007 7.712 r =6 77409 77311.8 .122 7.834 p=1-exp(-SUM/2)= .98010 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 6 to 13 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 944 944.3 .000 .000 r =5 21774 21743.9 .042 .042 r =6 77282 77311.8 .011 .053 p=1-exp(-SUM/2)= .02627 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 7 to 14 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 949 944.3 .023 .023 r =5 21869 21743.9 .720 .743 r =6 77182 77311.8 .218 .961 p=1-exp(-SUM/2)= .38154 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 8 to 15 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 952 944.3 .063 .063 r =5 21905 21743.9 1.194 1.256 r =6 77143 77311.8 .369 1.625 p=1-exp(-SUM/2)= .55623 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 9 to 16 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 888 944.3 3.357 3.357 r =5 22031 21743.9 3.791 7.148 r =6 77081 77311.8 .689 7.837 p=1-exp(-SUM/2)= .98013 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 10 to 17 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 986 944.3 1.841 1.841 r =5 21770 21743.9 .031 1.873 r =6 77244 77311.8 .059 1.932 p=1-exp(-SUM/2)= .61942 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 11 to 18 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 961 944.3 .295 .295 r =5 21719 21743.9 .029 .324 r =6 77320 77311.8 .001 .325 p=1-exp(-SUM/2)= .14985 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 12 to 19 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 946 944.3 .003 .003 r =5 21455 21743.9 3.838 3.842 r =6 77599 77311.8 1.067 4.908 p=1-exp(-SUM/2)= .91407 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 13 to 20 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 930 944.3 .217 .217 r =5 21641 21743.9 .487 .704 r =6 77429 77311.8 .178 .881 p=1-exp(-SUM/2)= .35635 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 14 to 21 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 964 944.3 .411 .411 r =5 21656 21743.9 .355 .766 r =6 77380 77311.8 .060 .826 p=1-exp(-SUM/2)= .33848 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 15 to 22 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 956 944.3 .145 .145 r =5 21534 21743.9 2.026 2.171 r =6 77510 77311.8 .508 2.679 p=1-exp(-SUM/2)= .73806 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 16 to 23 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 927 944.3 .317 .317 r =5 21446 21743.9 4.081 4.398 r =6 77627 77311.8 1.285 5.683 p=1-exp(-SUM/2)= .94167 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 17 to 24 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 876 944.3 4.940 4.940 r =5 21610 21743.9 .825 5.765 r =6 77514 77311.8 .529 6.294 p=1-exp(-SUM/2)= .95701 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 18 to 25 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 941 944.3 .012 .012 r =5 21526 21743.9 2.184 2.195 r =6 77533 77311.8 .633 2.828 p=1-exp(-SUM/2)= .75683 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 19 to 26 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 946 944.3 .003 .003 r =5 21627 21743.9 .628 .632 r =6 77427 77311.8 .172 .803 p=1-exp(-SUM/2)= .33075 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 20 to 27 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 919 944.3 .678 .678 r =5 21838 21743.9 .407 1.085 r =6 77243 77311.8 .061 1.146 p=1-exp(-SUM/2)= .43627 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 21 to 28 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 971 944.3 .755 .755 r =5 21636 21743.9 .535 1.290 r =6 77393 77311.8 .085 1.376 p=1-exp(-SUM/2)= .49731 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 22 to 29 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 922 944.3 .527 .527 r =5 21693 21743.9 .119 .646 r =6 77385 77311.8 .069 .715 p=1-exp(-SUM/2)= .30062 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 23 to 30 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 952 944.3 .063 .063 r =5 21786 21743.9 .082 .144 r =6 77262 77311.8 .032 .176 p=1-exp(-SUM/2)= .08441 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 24 to 31 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 947 944.3 .008 .008 r =5 21806 21743.9 .177 .185 r =6 77247 77311.8 .054 .239 p=1-exp(-SUM/2)= .11281 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bits.01 b-rank test for bits 25 to 32 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 980 944.3 1.350 1.350 r =5 21820 21743.9 .266 1.616 r =6 77200 77311.8 .162 1.778 p=1-exp(-SUM/2)= .58885 TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices These should be 25 uniform [0,1] random variables: .212054 .552269 .495881 .314024 .980101 .026275 .381544 .556235 .980125 .619424 .149847 .914068 .356352 .338477 .738057 .941673 .957011 .756835 .330746 .436274 .497314 .300624 .084405 .112808 .588849 brank test summary for bits.01 The KS test for those 25 supposed UNI's yields KS p-value= .240187 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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: 141383 missing words, -1.23 sigmas from mean, p-value= .10940 tst no 2: 141472 missing words, -1.02 sigmas from mean, p-value= .15344 tst no 3: 142025 missing words, .27 sigmas from mean, p-value= .60652 tst no 4: 141987 missing words, .18 sigmas from mean, p-value= .57200 tst no 5: 141752 missing words, -.37 sigmas from mean, p-value= .35659 tst no 6: 141502 missing words, -.95 sigmas from mean, p-value= .17062 tst no 7: 141439 missing words, -1.10 sigmas from mean, p-value= .13591 tst no 8: 141381 missing words, -1.23 sigmas from mean, p-value= .10852 tst no 9: 142087 missing words, .42 sigmas from mean, p-value= .66097 tst no 10: 141989 missing words, .19 sigmas from mean, p-value= .57384 tst no 11: 142355 missing words, 1.04 sigmas from mean, p-value= .85113 tst no 12: 141625 missing words, -.66 sigmas from mean, p-value= .25324 tst no 13: 141044 missing words, -2.02 sigmas from mean, p-value= .02160 tst no 14: 142958 missing words, 2.45 sigmas from mean, p-value= .99286 tst no 15: 141790 missing words, -.28 sigmas from mean, p-value= .39020 tst no 16: 142276 missing words, .86 sigmas from mean, p-value= .80420 tst no 17: 141882 missing words, -.06 sigmas from mean, p-value= .47454 tst no 18: 141222 missing words, -1.61 sigmas from mean, p-value= .05415 tst no 19: 141257 missing words, -1.52 sigmas from mean, p-value= .06374 tst no 20: 141310 missing words, -1.40 sigmas from mean, p-value= .08071 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bits.01 Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OPSO for bits.01 using bits 23 to 32 142333 1.461 .9280 OPSO for bits.01 using bits 22 to 31 141955 .157 .5626 OPSO for bits.01 using bits 21 to 30 141966 .195 .5775 OPSO for bits.01 using bits 20 to 29 141822 -.301 .3817 OPSO for bits.01 using bits 19 to 28 141845 -.222 .4122 OPSO for bits.01 using bits 18 to 27 142327 1.440 .9251 OPSO for bits.01 using bits 17 to 26 142083 .599 .7254 OPSO for bits.01 using bits 16 to 25 141454 -1.570 .0582 OPSO for bits.01 using bits 15 to 24 141484 -1.467 .0712 OPSO for bits.01 using bits 14 to 23 141881 -.098 .4611 OPSO for bits.01 using bits 13 to 22 141797 -.387 .3493 OPSO for bits.01 using bits 12 to 21 141616 -1.011 .1559 OPSO for bits.01 using bits 11 to 20 141950 .140 .5558 OPSO for bits.01 using bits 10 to 19 142167 .889 .8129 OPSO for bits.01 using bits 9 to 18 142099 .654 .7435 OPSO for bits.01 using bits 8 to 17 142360 1.554 .9399 OPSO for bits.01 using bits 7 to 16 142154 .844 .8006 OPSO for bits.01 using bits 6 to 15 141999 .309 .6214 OPSO for bits.01 using bits 5 to 14 142304 1.361 .9132 OPSO for bits.01 using bits 4 to 13 141811 -.339 .3673 OPSO for bits.01 using bits 3 to 12 141951 .144 .5571 OPSO for bits.01 using bits 2 to 11 141602 -1.060 .1446 OPSO for bits.01 using bits 1 to 10 141660 -.860 .1950 OQSO test for generator bits.01 Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OQSO for bits.01 using bits 28 to 32 142104 .660 .7453 OQSO for bits.01 using bits 27 to 31 141556 -1.198 .1155 OQSO for bits.01 using bits 26 to 30 142337 1.450 .9264 OQSO for bits.01 using bits 25 to 29 142024 .389 .6513 OQSO for bits.01 using bits 24 to 28 142235 1.104 .8652 OQSO for bits.01 using bits 23 to 27 141780 -.438 .3305 OQSO for bits.01 using bits 22 to 26 141661 -.842 .2000 OQSO for bits.01 using bits 21 to 25 141485 -1.438 .0752 OQSO for bits.01 using bits 20 to 24 142194 .965 .8327 OQSO for bits.01 using bits 19 to 23 141957 .162 .5642 OQSO for bits.01 using bits 18 to 22 141551 -1.215 .1122 OQSO for bits.01 using bits 17 to 21 142079 .575 .7174 OQSO for bits.01 using bits 16 to 20 141541 -1.249 .1059 OQSO for bits.01 using bits 15 to 19 141965 .189 .5748 OQSO for bits.01 using bits 14 to 18 141338 -1.937 .0264 OQSO for bits.01 using bits 13 to 17 141848 -.208 .4177 OQSO for bits.01 using bits 12 to 16 141926 .057 .5225 OQSO for bits.01 using bits 11 to 15 142073 .555 .7105 OQSO for bits.01 using bits 10 to 14 141938 .097 .5387 OQSO for bits.01 using bits 9 to 13 141909 -.001 .4996 OQSO for bits.01 using bits 8 to 12 141682 -.771 .2205 OQSO for bits.01 using bits 7 to 11 141979 .236 .5934 OQSO for bits.01 using bits 6 to 10 141492 -1.415 .0786 OQSO for bits.01 using bits 5 to 9 142157 .840 .7994 OQSO for bits.01 using bits 4 to 8 141731 -.605 .2728 OQSO for bits.01 using bits 3 to 7 141827 -.279 .3901 OQSO for bits.01 using bits 2 to 6 141813 -.327 .3720 OQSO for bits.01 using bits 1 to 5 141934 .084 .5333 DNA test for generator bits.01 Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p DNA for bits.01 using bits 31 to 32 141743 -.491 .3118 DNA for bits.01 using bits 30 to 31 141904 -.016 .4937 DNA for bits.01 using bits 29 to 30 141886 -.069 .4726 DNA for bits.01 using bits 28 to 29 141443 -1.376 .0845 DNA for bits.01 using bits 27 to 28 141625 -.839 .2008 DNA for bits.01 using bits 26 to 27 141986 .226 .5895 DNA for bits.01 using bits 25 to 26 141660 -.735 .2310 DNA for bits.01 using bits 24 to 25 141961 .152 .5606 DNA for bits.01 using bits 23 to 24 142021 .329 .6291 DNA for bits.01 using bits 22 to 23 141543 -1.081 .1399 DNA for bits.01 using bits 21 to 22 141903 -.019 .4926 DNA for bits.01 using bits 20 to 21 142093 .542 .7060 DNA for bits.01 using bits 19 to 20 142150 .710 .7611 DNA for bits.01 using bits 18 to 19 141968 .173 .5687 DNA for bits.01 using bits 17 to 18 141688 -.653 .2569 DNA for bits.01 using bits 16 to 17 141615 -.868 .1926 DNA for bits.01 using bits 15 to 16 141976 .197 .5780 DNA for bits.01 using bits 14 to 15 141387 -1.541 .0617 DNA for bits.01 using bits 13 to 14 141552 -1.054 .1459 DNA for bits.01 using bits 12 to 13 141112 -2.352 .0093 DNA for bits.01 using bits 11 to 12 142631 2.129 .9834 DNA for bits.01 using bits 10 to 11 142029 .353 .6380 DNA for bits.01 using bits 9 to 10 142307 1.173 .8796 DNA for bits.01 using bits 8 to 9 141553 -1.051 .1466 DNA for bits.01 using bits 7 to 8 141403 -1.494 .0676 DNA for bits.01 using bits 6 to 7 142120 .621 .7328 DNA for bits.01 using bits 5 to 6 140999 -2.685 .0036 DNA for bits.01 using bits 4 to 5 141319 -1.741 .0408 DNA for bits.01 using bits 3 to 4 141783 -.373 .3547 DNA for bits.01 using bits 2 to 3 141915 .017 .5067 DNA for bits.01 using bits 1 to 2 141797 -.331 .3702 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bits.01 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 bits.01 2503.44 .049 .519407 byte stream for bits.01 2422.42 -1.097 .136303 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 2460.28 -.562 .287128 bits 2 to 9 2506.08 .086 .534247 bits 3 to 10 2480.53 -.275 .391522 bits 4 to 11 2475.08 -.352 .362272 bits 5 to 12 2657.13 2.222 .986864 bits 6 to 13 2584.75 1.199 .884644 bits 7 to 14 2457.84 -.596 .275504 bits 8 to 15 2450.31 -.703 .241095 bits 9 to 16 2444.54 -.784 .216445 bits 10 to 17 2502.67 .038 .515060 bits 11 to 18 2543.76 .619 .732018 bits 12 to 19 2540.48 .573 .716512 bits 13 to 20 2521.35 .302 .618662 bits 14 to 21 2557.11 .808 .790338 bits 15 to 22 2527.74 .392 .652576 bits 16 to 23 2562.64 .886 .812171 bits 17 to 24 2474.26 -.364 .357905 bits 18 to 25 2505.16 .073 .529110 bits 19 to 26 2561.05 .863 .806054 bits 20 to 27 2419.20 -1.143 .126579 bits 21 to 28 2552.73 .746 .772099 bits 22 to 29 2499.10 -.013 .494933 bits 23 to 30 2386.60 -1.604 .054385 bits 24 to 31 2489.06 -.155 .438544 bits 25 to 32 2589.10 1.260 .896185 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bits.01 Of 12,000 tries, the average no. of successes should be 3523 with sigma=21.9 Successes: 3483 z-score: -1.826 p-value: .033889 Successes: 3515 z-score: -.365 p-value: .357445 Successes: 3557 z-score: 1.553 p-value: .939730 Successes: 3533 z-score: .457 p-value: .676028 Successes: 3474 z-score: -2.237 p-value: .012629 Successes: 3502 z-score: -.959 p-value: .168804 Successes: 3524 z-score: .046 p-value: .518210 Successes: 3532 z-score: .411 p-value: .659449 Successes: 3535 z-score: .548 p-value: .708135 Successes: 3517 z-score: -.274 p-value: .392053 square size avg. no. parked sample sigma 100. 3517.200 23.853 KSTEST for the above 10: p= .322348 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bits.01 Sample no. d^2 avg equiv uni 5 1.4375 1.0781 .764193 10 .2879 .8872 .251213 15 .2901 .8419 .252936 20 .6090 .7737 .457742 25 2.2817 .8518 .899058 30 .3598 .8918 .303411 35 4.7131 .9599 .991233 40 .7669 .9613 .537345 45 .8982 .9806 .594543 50 .8206 1.0138 .561645 55 .1539 1.0626 .143345 60 2.2340 1.1302 .894101 65 .3092 1.1329 .267123 70 .7167 1.1344 .513405 75 1.2047 1.1573 .702022 80 3.0614 1.1987 .953891 85 .8200 1.1601 .561371 90 1.1913 1.1344 .697998 95 .0014 1.1286 .001383 100 .3755 1.1300 .314342 MINIMUM DISTANCE TEST for bits.01 Result of KS test on 20 transformed mindist^2's: p-value= .719250 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bits.01 sample no: 1 r^3= 16.670 p-value= .42630 sample no: 2 r^3= 46.410 p-value= .78711 sample no: 3 r^3= 15.309 p-value= .39969 sample no: 4 r^3= 24.647 p-value= .56026 sample no: 5 r^3= 112.362 p-value= .97637 sample no: 6 r^3= 64.500 p-value= .88352 sample no: 7 r^3= 86.500 p-value= .94405 sample no: 8 r^3= 18.612 p-value= .46226 sample no: 9 r^3= 39.914 p-value= .73565 sample no: 10 r^3= 9.385 p-value= .26862 sample no: 11 r^3= 12.979 p-value= .35121 sample no: 12 r^3= 27.527 p-value= .60050 sample no: 13 r^3= 26.857 p-value= .59149 sample no: 14 r^3= .093 p-value= .00311 sample no: 15 r^3= 21.210 p-value= .50688 sample no: 16 r^3= 13.124 p-value= .35432 sample no: 17 r^3= 33.604 p-value= .67376 sample no: 18 r^3= 4.735 p-value= .14601 sample no: 19 r^3= .277 p-value= .00919 sample no: 20 r^3= 73.279 p-value= .91307 A KS test is applied to those 20 p-values. --------------------------------------------------------- 3DSPHERES test for file bits.01 p-value= .308999 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bits.01 Table of standardized frequency counts ( (obs-exp)/sqrt(exp) )^2 for j taking values <=6,7,8,...,47,>=48: 1.3 1.3 1.8 -.3 -.4 -.5 2.1 -.1 1.0 -.8 1.6 -1.0 -.8 -1.9 -.4 -.4 -.8 .5 .1 1.2 -.5 .7 .6 .6 1.0 -.6 .4 -.4 .6 .3 .9 -.1 -1.0 .2 -.1 -.7 -.7 .2 -.8 -.1 -.6 1.0 -1.1 Chi-square with 42 degrees of freedom: 33.239 z-score= -.956 p-value= .168895 ______________________________________________________________ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 .477987 Test no. 2 p-value .677283 Test no. 3 p-value .058675 Test no. 4 p-value .654743 Test no. 5 p-value .332991 Test no. 6 p-value .700416 Test no. 7 p-value .896112 Test no. 8 p-value .542135 Test no. 9 p-value .267096 Test no. 10 p-value .735717 Results of the OSUM test for bits.01 KSTEST on the above 10 p-values: .218357 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bits.01 Up and down runs in a sample of 10000 _________________________________________________ Run test for bits.01 : runs up; ks test for 10 p's: .226328 runs down; ks test for 10 p's: .040960 Run test for bits.01 : runs up; ks test for 10 p's: .744691 runs down; ks test for 10 p's: .414421 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bits.01 No. of wins: Observed Expected 98669 98585.86 98669= No. of wins, z-score= .372 pvalue= .64500 Analysis of Throws-per-Game: Chisq= 20.87 for 20 degrees of freedom, p= .59515 Throws Observed Expected Chisq Sum 1 66635 66666.7 .015 .015 2 37885 37654.3 1.413 1.428 3 26866 26954.7 .292 1.720 4 19234 19313.5 .327 2.047 5 13792 13851.4 .255 2.302 6 10060 9943.5 1.364 3.666 7 7153 7145.0 .009 3.675 8 5035 5139.1 2.108 5.782 9 3769 3699.9 1.292 7.074 10 2738 2666.3 1.928 9.003 11 1940 1923.3 .145 9.147 12 1423 1388.7 .845 9.992 13 948 1003.7 3.093 13.085 14 685 726.1 2.331 15.416 15 501 525.8 1.173 16.589 16 353 381.2 2.079 18.668 17 256 276.5 1.526 20.193 18 193 200.8 .305 20.499 19 147 146.0 .007 20.506 20 100 106.2 .364 20.870 21 287 287.1 .000 20.870 SUMMARY FOR bits.01 p-value for no. of wins: .644999 p-value for throws/game: .595154 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Results of DIEHARD battery of tests sent to file bits01.out