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 rtwist.txt For a sample of size 500: mean rtwist.txt using bits 1 to 24 1.960 duplicate number number spacings observed expected 0 78. 67.668 1 137. 135.335 2 132. 135.335 3 77. 90.224 4 48. 45.112 5 20. 18.045 6 to INF 8. 8.282 Chisquare with 6 d.o.f. = 4.02 p-value= .326683 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean rtwist.txt using bits 2 to 25 2.008 duplicate number number spacings observed expected 0 76. 67.668 1 125. 135.335 2 122. 135.335 3 106. 90.224 4 48. 45.112 5 16. 18.045 6 to INF 7. 8.282 Chisquare with 6 d.o.f. = 6.50 p-value= .630737 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean rtwist.txt using bits 3 to 26 1.978 duplicate number number spacings observed expected 0 72. 67.668 1 142. 135.335 2 122. 135.335 3 88. 90.224 4 51. 45.112 5 17. 18.045 6 to INF 8. 8.282 Chisquare with 6 d.o.f. = 2.81 p-value= .168077 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean rtwist.txt using bits 4 to 27 2.204 duplicate number number spacings observed expected 0 49. 67.668 1 124. 135.335 2 144. 135.335 3 98. 90.224 4 47. 45.112 5 24. 18.045 6 to INF 14. 8.282 Chisquare with 6 d.o.f. = 13.32 p-value= .961730 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean rtwist.txt using bits 5 to 28 2.070 duplicate number number spacings observed expected 0 62. 67.668 1 130. 135.335 2 136. 135.335 3 96. 90.224 4 45. 45.112 5 21. 18.045 6 to INF 10. 8.282 Chisquare with 6 d.o.f. = 1.90 p-value= .071241 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean rtwist.txt using bits 6 to 29 2.066 duplicate number number spacings observed expected 0 62. 67.668 1 133. 135.335 2 134. 135.335 3 96. 90.224 4 46. 45.112 5 19. 18.045 6 to INF 10. 8.282 Chisquare with 6 d.o.f. = 1.32 p-value= .029600 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean rtwist.txt using bits 7 to 30 2.026 duplicate number number spacings observed expected 0 69. 67.668 1 136. 135.335 2 132. 135.335 3 84. 90.224 4 47. 45.112 5 24. 18.045 6 to INF 8. 8.282 Chisquare with 6 d.o.f. = 2.60 p-value= .142317 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean rtwist.txt using bits 8 to 31 2.054 duplicate number number spacings observed expected 0 56. 67.668 1 153. 135.335 2 124. 135.335 3 91. 90.224 4 46. 45.112 5 20. 18.045 6 to INF 10. 8.282 Chisquare with 6 d.o.f. = 5.86 p-value= .560879 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean rtwist.txt using bits 9 to 32 2.060 duplicate number number spacings observed expected 0 72. 67.668 1 123. 135.335 2 131. 135.335 3 98. 90.224 4 44. 45.112 5 22. 18.045 6 to INF 10. 8.282 Chisquare with 6 d.o.f. = 3.46 p-value= .250938 ::::::::::::::::::::::::::::::::::::::::: The 9 p-values were .326683 .630737 .168077 .961730 .071241 .029600 .142317 .560879 .250938 A KSTEST for the 9 p-values yields .833794 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 rtwist.txt For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom=103.620; p-value= .644568 OPERM5 test for file rtwist.txt For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom= 95.927; p-value= .431208 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 rtwist.txt Rank test for 31x31 binary matrices: rows from leftmost 31 bits of each 32-bit integer rank observed expected (o-e)^2/e sum 28 228 211.4 1.300562 1.301 29 5110 5134.0 .112289 1.413 30 23107 23103.0 .000676 1.414 31 11555 11551.5 .001046 1.415 chisquare= 1.415 for 3 d. of f.; p-value= .415027 -------------------------------------------------------------- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 rtwist.txt Rank test for 32x32 binary matrices: rows from leftmost 32 bits of each 32-bit integer rank observed expected (o-e)^2/e sum 29 207 211.4 .092324 .092 30 5010 5134.0 2.995425 3.088 31 23188 23103.0 .312384 3.400 32 11595 11551.5 .163626 3.564 chisquare= 3.564 for 3 d. of f.; p-value= .716941 -------------------------------------------------------------- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 rtwist.txt Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 1 to 8 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 904 944.3 1.720 1.720 r =5 21911 21743.9 1.284 3.004 r =6 77185 77311.8 .208 3.212 p=1-exp(-SUM/2)= .79932 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 2 to 9 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 953 944.3 .080 .080 r =5 21900 21743.9 1.121 1.201 r =6 77147 77311.8 .351 1.552 p=1-exp(-SUM/2)= .53978 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 3 to 10 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 968 944.3 .595 .595 r =5 21903 21743.9 1.164 1.759 r =6 77129 77311.8 .432 2.191 p=1-exp(-SUM/2)= .66565 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 4 to 11 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 956 944.3 .145 .145 r =5 21838 21743.9 .407 .552 r =6 77206 77311.8 .145 .697 p=1-exp(-SUM/2)= .29424 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 5 to 12 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 990 944.3 2.212 2.212 r =5 21649 21743.9 .414 2.626 r =6 77361 77311.8 .031 2.657 p=1-exp(-SUM/2)= .73513 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 6 to 13 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 916 944.3 .848 .848 r =5 21952 21743.9 1.992 2.840 r =6 77132 77311.8 .418 3.258 p=1-exp(-SUM/2)= .80387 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 7 to 14 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 944 944.3 .000 .000 r =5 21857 21743.9 .588 .588 r =6 77199 77311.8 .165 .753 p=1-exp(-SUM/2)= .31373 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 8 to 15 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 947 944.3 .008 .008 r =5 21724 21743.9 .018 .026 r =6 77329 77311.8 .004 .030 p=1-exp(-SUM/2)= .01477 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 9 to 16 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 915 944.3 .909 .909 r =5 21763 21743.9 .017 .926 r =6 77322 77311.8 .001 .927 p=1-exp(-SUM/2)= .37102 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 10 to 17 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 942 944.3 .006 .006 r =5 21723 21743.9 .020 .026 r =6 77335 77311.8 .007 .033 p=1-exp(-SUM/2)= .01620 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 11 to 18 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 961 944.3 .295 .295 r =5 21787 21743.9 .085 .381 r =6 77252 77311.8 .046 .427 p=1-exp(-SUM/2)= .19224 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 12 to 19 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 902 944.3 1.895 1.895 r =5 21642 21743.9 .478 2.372 r =6 77456 77311.8 .269 2.641 p=1-exp(-SUM/2)= .73306 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 13 to 20 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 985 944.3 1.754 1.754 r =5 21634 21743.9 .555 2.310 r =6 77381 77311.8 .062 2.371 p=1-exp(-SUM/2)= .69448 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 14 to 21 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 911 944.3 1.174 1.174 r =5 21811 21743.9 .207 1.381 r =6 77278 77311.8 .015 1.396 p=1-exp(-SUM/2)= .50248 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 15 to 22 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 948 944.3 .014 .014 r =5 21698 21743.9 .097 .111 r =6 77354 77311.8 .023 .134 p=1-exp(-SUM/2)= .06500 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 16 to 23 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 946 944.3 .003 .003 r =5 21643 21743.9 .468 .471 r =6 77411 77311.8 .127 .599 p=1-exp(-SUM/2)= .25864 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 17 to 24 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 957 944.3 .171 .171 r =5 21785 21743.9 .078 .248 r =6 77258 77311.8 .037 .286 p=1-exp(-SUM/2)= .13320 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 18 to 25 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 917 944.3 .789 .789 r =5 22063 21743.9 4.683 5.472 r =6 77020 77311.8 1.101 6.574 p=1-exp(-SUM/2)= .96263 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 19 to 26 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 970 944.3 .699 .699 r =5 21857 21743.9 .588 1.288 r =6 77173 77311.8 .249 1.537 p=1-exp(-SUM/2)= .53626 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 20 to 27 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 970 944.3 .699 .699 r =5 21711 21743.9 .050 .749 r =6 77319 77311.8 .001 .750 p=1-exp(-SUM/2)= .31265 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 21 to 28 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 954 944.3 .100 .100 r =5 21801 21743.9 .150 .250 r =6 77245 77311.8 .058 .307 p=1-exp(-SUM/2)= .14242 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 22 to 29 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 937 944.3 .056 .056 r =5 21665 21743.9 .286 .343 r =6 77398 77311.8 .096 .439 p=1-exp(-SUM/2)= .19702 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 23 to 30 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 964 944.3 .411 .411 r =5 21683 21743.9 .171 .581 r =6 77353 77311.8 .022 .603 p=1-exp(-SUM/2)= .26046 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 24 to 31 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 966 944.3 .499 .499 r =5 21933 21743.9 1.645 2.143 r =6 77101 77311.8 .575 2.718 p=1-exp(-SUM/2)= .74307 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG rtwist.txt b-rank test for bits 25 to 32 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 963 944.3 .370 .370 r =5 21812 21743.9 .213 .584 r =6 77225 77311.8 .097 .681 p=1-exp(-SUM/2)= .28859 TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices These should be 25 uniform [0,1] random variables: .799323 .539776 .665649 .294240 .735132 .803874 .313730 .014765 .371025 .016196 .192243 .733055 .694481 .502478 .064997 .258643 .133202 .962627 .536261 .312652 .142421 .197020 .260458 .743075 .288589 brank test summary for rtwist.txt The KS test for those 25 supposed UNI's yields KS p-value= .722870 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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: 141832 missing words, -.18 sigmas from mean, p-value= .42831 tst no 2: 141513 missing words, -.93 sigmas from mean, p-value= .17722 tst no 3: 141905 missing words, -.01 sigmas from mean, p-value= .49597 tst no 4: 141499 missing words, -.96 sigmas from mean, p-value= .16885 tst no 5: 142135 missing words, .53 sigmas from mean, p-value= .70100 tst no 6: 141930 missing words, .05 sigmas from mean, p-value= .51926 tst no 7: 141571 missing words, -.79 sigmas from mean, p-value= .21462 tst no 8: 141564 missing words, -.81 sigmas from mean, p-value= .20988 tst no 9: 142246 missing words, .79 sigmas from mean, p-value= .78425 tst no 10: 141689 missing words, -.51 sigmas from mean, p-value= .30335 tst no 11: 141727 missing words, -.43 sigmas from mean, p-value= .33505 tst no 12: 142040 missing words, .31 sigmas from mean, p-value= .61993 tst no 13: 141890 missing words, -.05 sigmas from mean, p-value= .48199 tst no 14: 142486 missing words, 1.35 sigmas from mean, p-value= .91107 tst no 15: 141914 missing words, .01 sigmas from mean, p-value= .50435 tst no 16: 142366 missing words, 1.07 sigmas from mean, p-value= .85701 tst no 17: 141505 missing words, -.94 sigmas from mean, p-value= .17241 tst no 18: 142165 missing words, .60 sigmas from mean, p-value= .72487 tst no 19: 141787 missing words, -.29 sigmas from mean, p-value= .38751 tst no 20: 141471 missing words, -1.02 sigmas from mean, p-value= .15289 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 rtwist.txt Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OPSO for rtwist.txt using bits 23 to 32 141839 -.243 .4042 OPSO for rtwist.txt using bits 22 to 31 142034 .430 .6664 OPSO for rtwist.txt using bits 21 to 30 142132 .768 .7787 OPSO for rtwist.txt using bits 20 to 29 142338 1.478 .9303 OPSO for rtwist.txt using bits 19 to 28 142147 .820 .7938 OPSO for rtwist.txt using bits 18 to 27 142078 .582 .7196 OPSO for rtwist.txt using bits 17 to 26 142111 .695 .7566 OPSO for rtwist.txt using bits 16 to 25 142731 2.833 .9977 OPSO for rtwist.txt using bits 15 to 24 142235 1.123 .8693 OPSO for rtwist.txt using bits 14 to 23 141817 -.318 .3751 OPSO for rtwist.txt using bits 13 to 22 142284 1.292 .9018 OPSO for rtwist.txt using bits 12 to 21 141859 -.174 .4311 OPSO for rtwist.txt using bits 11 to 20 141847 -.215 .4149 OPSO for rtwist.txt using bits 10 to 19 142028 .409 .6588 OPSO for rtwist.txt using bits 9 to 18 142155 .847 .8015 OPSO for rtwist.txt using bits 8 to 17 141656 -.874 .1912 OPSO for rtwist.txt using bits 7 to 16 141967 .199 .5788 OPSO for rtwist.txt using bits 6 to 15 142378 1.616 .9470 OPSO for rtwist.txt using bits 5 to 14 141618 -1.005 .1575 OPSO for rtwist.txt using bits 4 to 13 141790 -.411 .3404 OPSO for rtwist.txt using bits 3 to 12 142233 1.116 .8678 OPSO for rtwist.txt using bits 2 to 11 142117 .716 .7630 OPSO for rtwist.txt using bits 1 to 10 141932 .078 .5312 OQSO test for generator rtwist.txt Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OQSO for rtwist.txt using bits 28 to 32 142345 1.477 .9301 OQSO for rtwist.txt using bits 27 to 31 142079 .575 .7174 OQSO for rtwist.txt using bits 26 to 30 141901 -.028 .4887 OQSO for rtwist.txt using bits 25 to 29 141845 -.218 .4137 OQSO for rtwist.txt using bits 24 to 28 141965 .189 .5748 OQSO for rtwist.txt using bits 23 to 27 140961 -3.215 .0007 OQSO for rtwist.txt using bits 22 to 26 141822 -.296 .3836 OQSO for rtwist.txt using bits 21 to 25 142111 .684 .7529 OQSO for rtwist.txt using bits 20 to 24 141911 .006 .5023 OQSO for rtwist.txt using bits 19 to 23 141831 -.266 .3953 OQSO for rtwist.txt using bits 18 to 22 141743 -.564 .2864 OQSO for rtwist.txt using bits 17 to 21 141887 -.076 .4698 OQSO for rtwist.txt using bits 16 to 20 142147 .806 .7898 OQSO for rtwist.txt using bits 15 to 19 141839 -.238 .4058 OQSO for rtwist.txt using bits 14 to 18 141907 -.008 .4969 OQSO for rtwist.txt using bits 13 to 17 142021 .379 .6475 OQSO for rtwist.txt using bits 12 to 16 141608 -1.021 .1535 OQSO for rtwist.txt using bits 11 to 15 142427 1.755 .9604 OQSO for rtwist.txt using bits 10 to 14 142011 .345 .6348 OQSO for rtwist.txt using bits 9 to 13 141633 -.937 .1745 OQSO for rtwist.txt using bits 8 to 12 142054 .490 .6881 OQSO for rtwist.txt using bits 7 to 11 141980 .240 .5947 OQSO for rtwist.txt using bits 6 to 10 142101 .650 .7421 OQSO for rtwist.txt using bits 5 to 9 142089 .609 .7288 OQSO for rtwist.txt using bits 4 to 8 141647 -.889 .1869 OQSO for rtwist.txt using bits 3 to 7 142137 .772 .7799 OQSO for rtwist.txt using bits 2 to 6 141868 -.140 .4443 OQSO for rtwist.txt using bits 1 to 5 141908 -.005 .4982 DNA test for generator rtwist.txt Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p DNA for rtwist.txt using bits 31 to 32 142449 1.592 .9443 DNA for rtwist.txt using bits 30 to 31 142147 .701 .7584 DNA for rtwist.txt using bits 29 to 30 141809 -.296 .3836 DNA for rtwist.txt using bits 28 to 29 141714 -.576 .2822 DNA for rtwist.txt using bits 27 to 28 142000 .267 .6054 DNA for rtwist.txt using bits 26 to 27 142185 .813 .7919 DNA for rtwist.txt using bits 25 to 26 141826 -.246 .4029 DNA for rtwist.txt using bits 24 to 25 141774 -.399 .3449 DNA for rtwist.txt using bits 23 to 24 141441 -1.381 .0836 DNA for rtwist.txt using bits 22 to 23 141683 -.668 .2522 DNA for rtwist.txt using bits 21 to 22 141758 -.446 .3277 DNA for rtwist.txt using bits 20 to 21 141829 -.237 .4063 DNA for rtwist.txt using bits 19 to 20 141773 -.402 .3438 DNA for rtwist.txt using bits 18 to 19 142599 2.034 .9790 DNA for rtwist.txt using bits 17 to 18 142076 .492 .6885 DNA for rtwist.txt using bits 16 to 17 141945 .105 .5419 DNA for rtwist.txt using bits 15 to 16 142197 .849 .8019 DNA for rtwist.txt using bits 14 to 15 142419 1.503 .9336 DNA for rtwist.txt using bits 13 to 14 142417 1.498 .9329 DNA for rtwist.txt using bits 12 to 13 142154 .722 .7648 DNA for rtwist.txt using bits 11 to 12 141605 -.898 .1847 DNA for rtwist.txt using bits 10 to 11 141940 .090 .5360 DNA for rtwist.txt using bits 9 to 10 142381 1.391 .9179 DNA for rtwist.txt using bits 8 to 9 142029 .353 .6380 DNA for rtwist.txt using bits 7 to 8 141686 -.659 .2550 DNA for rtwist.txt using bits 6 to 7 142513 1.781 .9625 DNA for rtwist.txt using bits 5 to 6 141176 -2.163 .0153 DNA for rtwist.txt using bits 4 to 5 141517 -1.157 .1236 DNA for rtwist.txt using bits 3 to 4 142093 .542 .7060 DNA for rtwist.txt using bits 2 to 3 141730 -.529 .2984 DNA for rtwist.txt using bits 1 to 2 141439 -1.387 .0827 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 rtwist.txt Chi-square with 5^5-5^4=2500 d.of f. for sample size:2560000 chisquare equiv normal p-value Results fo COUNT-THE-1's in successive bytes: byte stream for rtwist.txt 2516.27 .230 .590991 byte stream for rtwist.txt 2436.60 -.897 .184972 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 2494.57 -.077 .469394 bits 2 to 9 2451.59 -.685 .246780 bits 3 to 10 2560.76 .859 .804913 bits 4 to 11 2615.40 1.632 .948663 bits 5 to 12 2469.32 -.434 .332169 bits 6 to 13 2641.27 1.998 .977133 bits 7 to 14 2540.94 .579 .718694 bits 8 to 15 2538.92 .550 .708965 bits 9 to 16 2544.18 .625 .733956 bits 10 to 17 2566.45 .940 .826310 bits 11 to 18 2596.19 1.360 .913128 bits 12 to 19 2461.15 -.549 .291352 bits 13 to 20 2568.89 .974 .835043 bits 14 to 21 2491.77 -.116 .453652 bits 15 to 22 2482.37 -.249 .401570 bits 16 to 23 2457.32 -.604 .273044 bits 17 to 24 2683.58 2.596 .995287 bits 18 to 25 2485.27 -.208 .417499 bits 19 to 26 2545.25 .640 .738896 bits 20 to 27 2499.83 -.002 .499036 bits 21 to 28 2619.72 1.693 .954775 bits 22 to 29 2490.42 -.136 .446101 bits 23 to 30 2474.82 -.356 .360887 bits 24 to 31 2581.41 1.151 .875190 bits 25 to 32 2633.90 1.894 .970866 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 rtwist.txt Of 12,000 tries, the average no. of successes should be 3523 with sigma=21.9 Successes: 3549 z-score: 1.187 p-value: .882429 Successes: 3502 z-score: -.959 p-value: .168804 Successes: 3530 z-score: .320 p-value: .625377 Successes: 3545 z-score: 1.005 p-value: .842447 Successes: 3483 z-score: -1.826 p-value: .033889 Successes: 3546 z-score: 1.050 p-value: .853193 Successes: 3505 z-score: -.822 p-value: .205562 Successes: 3531 z-score: .365 p-value: .642555 Successes: 3512 z-score: -.502 p-value: .307734 Successes: 3531 z-score: .365 p-value: .642555 square size avg. no. parked sample sigma 100. 3523.400 20.853 KSTEST for the above 10: p= .131392 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 rtwist.txt Sample no. d^2 avg equiv uni 5 .6519 1.0014 .480666 10 .5030 1.3671 .396829 15 .1406 1.0636 .131783 20 .0224 .9535 .022297 25 1.0335 .8789 .646068 30 2.6169 .9614 .927926 35 .3009 1.0033 .260980 40 2.2215 1.0221 .892760 45 1.5346 1.0102 .786108 50 1.2080 1.0548 .703028 55 .1986 1.0457 .180951 60 2.0388 1.0965 .871143 65 .1106 1.0933 .105240 70 .4928 1.0676 .390576 75 .6315 1.0523 .469917 80 .7057 1.0288 .507994 85 2.0079 1.0457 .867075 90 1.7532 1.0437 .828302 95 .2385 1.0282 .213132 100 .7888 1.0073 .547408 MINIMUM DISTANCE TEST for rtwist.txt Result of KS test on 20 transformed mindist^2's: p-value= .200057 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 rtwist.txt sample no: 1 r^3= 14.122 p-value= .37546 sample no: 2 r^3= 106.223 p-value= .97101 sample no: 3 r^3= 15.581 p-value= .40511 sample no: 4 r^3= 4.610 p-value= .14245 sample no: 5 r^3= 37.725 p-value= .71563 sample no: 6 r^3= 24.154 p-value= .55298 sample no: 7 r^3= 14.966 p-value= .39279 sample no: 8 r^3= 12.918 p-value= .34987 sample no: 9 r^3= 40.686 p-value= .74236 sample no: 10 r^3= 29.161 p-value= .62169 sample no: 11 r^3= 82.181 p-value= .93539 sample no: 12 r^3= 28.014 p-value= .60695 sample no: 13 r^3= 19.658 p-value= .48069 sample no: 14 r^3= 51.599 p-value= .82093 sample no: 15 r^3= 15.114 p-value= .39578 sample no: 16 r^3= 4.338 p-value= .13462 sample no: 17 r^3= 8.172 p-value= .23846 sample no: 18 r^3= 1.686 p-value= .05466 sample no: 19 r^3= 59.473 p-value= .86227 sample no: 20 r^3= 63.004 p-value= .87756 A KS test is applied to those 20 p-values. --------------------------------------------------------- 3DSPHERES test for file rtwist.txt p-value= .071709 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 rtwist.txt Table of standardized frequency counts ( (obs-exp)/sqrt(exp) )^2 for j taking values <=6,7,8,...,47,>=48: 1.3 .1 .6 -.3 -2.1 1.1 .0 -.5 -1.1 1.8 .4 -1.2 2.7 -.9 -1.0 .6 -.6 .2 -.3 -.1 .2 -.9 .3 .9 -1.8 -.6 1.1 .8 -1.0 2.3 1.2 .4 -.5 -.2 -1.2 .4 -.7 -1.0 .5 1.5 .1 .0 -.1 Chi-square with 42 degrees of freedom: 44.772 z-score= .302 p-value= .643860 ______________________________________________________________ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 .302200 Test no. 2 p-value .561856 Test no. 3 p-value .490416 Test no. 4 p-value .052409 Test no. 5 p-value .715492 Test no. 6 p-value .209100 Test no. 7 p-value .642280 Test no. 8 p-value .467903 Test no. 9 p-value .084727 Test no. 10 p-value .104447 Results of the OSUM test for rtwist.txt KSTEST on the above 10 p-values: .785769 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 rtwist.txt Up and down runs in a sample of 10000 _________________________________________________ Run test for rtwist.txt : runs up; ks test for 10 p's: .681192 runs down; ks test for 10 p's: .192169 Run test for rtwist.txt : runs up; ks test for 10 p's: .326488 runs down; ks test for 10 p's: .653785 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 rtwist.txt No. of wins: Observed Expected 98680 98585.86 98680= No. of wins, z-score= .421 pvalue= .66314 Analysis of Throws-per-Game: Chisq= 16.65 for 20 degrees of freedom, p= .32417 Throws Observed Expected Chisq Sum 1 66679 66666.7 .002 .002 2 37585 37654.3 .128 .130 3 26824 26954.7 .634 .764 4 19270 19313.5 .098 .862 5 13957 13851.4 .805 1.667 6 9988 9943.5 .199 1.865 7 7058 7145.0 1.060 2.925 8 5124 5139.1 .044 2.969 9 3707 3699.9 .014 2.983 10 2739 2666.3 1.982 4.966 11 1945 1923.3 .244 5.210 12 1427 1388.7 1.054 6.264 13 1048 1003.7 1.954 8.218 14 733 726.1 .065 8.283 15 511 525.8 .419 8.701 16 402 381.2 1.140 9.842 17 256 276.5 1.526 11.367 18 201 200.8 .000 11.367 19 134 146.0 .984 12.351 20 95 106.2 1.184 13.535 21 317 287.1 3.111 16.646 SUMMARY FOR rtwist.txt p-value for no. of wins: .663141 p-value for throws/game: .324167 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Results of DIEHARD battery of tests sent to file t.txt