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 random.dat For a sample of size 500: mean random.dat using bits 1 to 24 1.882 duplicate number number spacings observed expected 0 76. 67.668 1 135. 135.335 2 150. 135.335 3 81. 90.224 4 36. 45.112 5 16. 18.045 6 to INF 6. 8.282 Chisquare with 6 d.o.f. = 6.26 p-value= .605253 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean random.dat using bits 2 to 25 2.068 duplicate number number spacings observed expected 0 66. 67.668 1 124. 135.335 2 146. 135.335 3 83. 90.224 4 44. 45.112 5 30. 18.045 6 to INF 7. 8.282 Chisquare with 6 d.o.f. = 10.56 p-value= .896888 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean random.dat using bits 3 to 26 1.908 duplicate number number spacings observed expected 0 80. 67.668 1 142. 135.335 2 127. 135.335 3 88. 90.224 4 35. 45.112 5 19. 18.045 6 to INF 9. 8.282 Chisquare with 6 d.o.f. = 5.52 p-value= .521359 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean random.dat using bits 4 to 27 2.056 duplicate number number spacings observed expected 0 65. 67.668 1 141. 135.335 2 126. 135.335 3 87. 90.224 4 45. 45.112 5 25. 18.045 6 to INF 11. 8.282 Chisquare with 6 d.o.f. = 4.67 p-value= .413842 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean random.dat using bits 5 to 28 2.006 duplicate number number spacings observed expected 0 65. 67.668 1 140. 135.335 2 133. 135.335 3 94. 90.224 4 37. 45.112 5 21. 18.045 6 to INF 10. 8.282 Chisquare with 6 d.o.f. = 2.76 p-value= .162098 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean random.dat using bits 6 to 29 2.002 duplicate number number spacings observed expected 0 74. 67.668 1 122. 135.335 2 136. 135.335 3 103. 90.224 4 42. 45.112 5 14. 18.045 6 to INF 9. 8.282 Chisquare with 6 d.o.f. = 4.90 p-value= .443642 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean random.dat using bits 7 to 30 2.144 duplicate number number spacings observed expected 0 49. 67.668 1 132. 135.335 2 136. 135.335 3 100. 90.224 4 56. 45.112 5 19. 18.045 6 to INF 8. 8.282 Chisquare with 6 d.o.f. = 8.98 p-value= .825457 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean random.dat using bits 8 to 31 2.012 duplicate number number spacings observed expected 0 69. 67.668 1 131. 135.335 2 133. 135.335 3 94. 90.224 4 47. 45.112 5 18. 18.045 6 to INF 8. 8.282 Chisquare with 6 d.o.f. = .45 p-value= .001628 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean random.dat using bits 9 to 32 1.900 duplicate number number spacings observed expected 0 67. 67.668 1 143. 135.335 2 142. 135.335 3 88. 90.224 4 43. 45.112 5 15. 18.045 6 to INF 2. 8.282 Chisquare with 6 d.o.f. = 6.20 p-value= .598953 ::::::::::::::::::::::::::::::::::::::::: The 9 p-values were .605253 .896888 .521359 .413842 .162098 .443642 .825457 .001628 .598953 A KSTEST for the 9 p-values yields .308247 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 random.dat For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom= 93.646; p-value= .366856 OPERM5 test for file random.dat For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom=117.509; p-value= .901192 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 random.dat Rank test for 31x31 binary matrices: rows from leftmost 31 bits of each 32-bit integer rank observed expected (o-e)^2/e sum 28 210 211.4 .009511 .010 29 5122 5134.0 .028096 .038 30 23246 23103.0 .884541 .922 31 11422 11551.5 1.452326 2.374 chisquare= 2.374 for 3 d. of f.; p-value= .563263 -------------------------------------------------------------- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 random.dat 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 215 211.4 .060688 .061 30 5085 5134.0 .467861 .529 31 23044 23103.0 .150912 .679 32 11656 11551.5 .944910 1.624 chisquare= 1.624 for 3 d. of f.; p-value= .447366 -------------------------------------------------------------- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 random.dat Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 1 to 8 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 911 944.3 1.174 1.174 r =5 21666 21743.9 .279 1.453 r =6 77423 77311.8 .160 1.613 p=1-exp(-SUM/2)= .55367 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 2 to 9 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 894 944.3 2.679 2.679 r =5 21711 21743.9 .050 2.729 r =6 77395 77311.8 .090 2.819 p=1-exp(-SUM/2)= .75571 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 3 to 10 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 923 944.3 .481 .481 r =5 21542 21743.9 1.875 2.355 r =6 77535 77311.8 .644 3.000 p=1-exp(-SUM/2)= .77682 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 4 to 11 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 959 944.3 .229 .229 r =5 21449 21743.9 4.000 4.228 r =6 77592 77311.8 1.015 5.244 p=1-exp(-SUM/2)= .92734 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 5 to 12 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 910 944.3 1.246 1.246 r =5 21733 21743.9 .005 1.251 r =6 77357 77311.8 .026 1.278 p=1-exp(-SUM/2)= .47214 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 6 to 13 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 946 944.3 .003 .003 r =5 22023 21743.9 3.582 3.586 r =6 77031 77311.8 1.020 4.605 p=1-exp(-SUM/2)= .90001 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 7 to 14 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 942 944.3 .006 .006 r =5 21798 21743.9 .135 .140 r =6 77260 77311.8 .035 .175 p=1-exp(-SUM/2)= .08375 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 8 to 15 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 998 944.3 3.054 3.054 r =5 21642 21743.9 .478 3.531 r =6 77360 77311.8 .030 3.561 p=1-exp(-SUM/2)= .83147 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 9 to 16 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 930 944.3 .217 .217 r =5 21741 21743.9 .000 .217 r =6 77329 77311.8 .004 .221 p=1-exp(-SUM/2)= .10452 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 10 to 17 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 921 944.3 .575 .575 r =5 21705 21743.9 .070 .645 r =6 77374 77311.8 .050 .695 p=1-exp(-SUM/2)= .29341 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 11 to 18 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 969 944.3 .646 .646 r =5 21575 21743.9 1.312 1.958 r =6 77456 77311.8 .269 2.227 p=1-exp(-SUM/2)= .67158 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 12 to 19 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 931 944.3 .187 .187 r =5 21706 21743.9 .066 .253 r =6 77363 77311.8 .034 .287 p=1-exp(-SUM/2)= .13382 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 13 to 20 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 949 944.3 .023 .023 r =5 21794 21743.9 .115 .139 r =6 77257 77311.8 .039 .178 p=1-exp(-SUM/2)= .08500 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 14 to 21 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 971 944.3 .755 .755 r =5 21547 21743.9 1.783 2.538 r =6 77482 77311.8 .375 2.913 p=1-exp(-SUM/2)= .76690 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 15 to 22 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 948 944.3 .014 .014 r =5 21746 21743.9 .000 .015 r =6 77306 77311.8 .000 .015 p=1-exp(-SUM/2)= .00753 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 16 to 23 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 983 944.3 1.586 1.586 r =5 21663 21743.9 .301 1.887 r =6 77354 77311.8 .023 1.910 p=1-exp(-SUM/2)= .61518 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 17 to 24 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 936 944.3 .073 .073 r =5 21718 21743.9 .031 .104 r =6 77346 77311.8 .015 .119 p=1-exp(-SUM/2)= .05774 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 18 to 25 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 1006 944.3 4.031 4.031 r =5 21706 21743.9 .066 4.097 r =6 77288 77311.8 .007 4.105 p=1-exp(-SUM/2)= .87156 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 19 to 26 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 998 944.3 3.054 3.054 r =5 21818 21743.9 .253 3.306 r =6 77184 77311.8 .211 3.517 p=1-exp(-SUM/2)= .82773 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 20 to 27 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 929 944.3 .248 .248 r =5 21729 21743.9 .010 .258 r =6 77342 77311.8 .012 .270 p=1-exp(-SUM/2)= .12626 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 21 to 28 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 924 944.3 .436 .436 r =5 21683 21743.9 .171 .607 r =6 77393 77311.8 .085 .692 p=1-exp(-SUM/2)= .29259 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 22 to 29 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 928 944.3 .281 .281 r =5 21632 21743.9 .576 .857 r =6 77440 77311.8 .213 1.070 p=1-exp(-SUM/2)= .41429 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 23 to 30 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 945 944.3 .001 .001 r =5 21570 21743.9 1.391 1.391 r =6 77485 77311.8 .388 1.779 p=1-exp(-SUM/2)= .58920 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 24 to 31 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 946 944.3 .003 .003 r =5 21897 21743.9 1.078 1.081 r =6 77157 77311.8 .310 1.391 p=1-exp(-SUM/2)= .50118 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG random.dat b-rank test for bits 25 to 32 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 981 944.3 1.426 1.426 r =5 21775 21743.9 .044 1.471 r =6 77244 77311.8 .059 1.530 p=1-exp(-SUM/2)= .53471 TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices These should be 25 uniform [0,1] random variables: .553672 .755706 .776823 .927337 .472143 .900013 .083746 .831465 .104525 .293408 .671579 .133819 .085001 .766898 .007535 .615179 .057742 .871565 .827734 .126259 .292592 .414285 .589202 .501177 .534709 brank test summary for random.dat The KS test for those 25 supposed UNI's yields KS p-value= .221964 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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: 141681 missing words, -.53 sigmas from mean, p-value= .29685 tst no 2: 142285 missing words, .88 sigmas from mean, p-value= .80996 tst no 3: 141880 missing words, -.07 sigmas from mean, p-value= .47268 tst no 4: 142051 missing words, .33 sigmas from mean, p-value= .62968 tst no 5: 141610 missing words, -.70 sigmas from mean, p-value= .24216 tst no 6: 142441 missing words, 1.24 sigmas from mean, p-value= .89292 tst no 7: 141851 missing words, -.14 sigmas from mean, p-value= .44580 tst no 8: 142635 missing words, 1.70 sigmas from mean, p-value= .95501 tst no 9: 141740 missing words, -.40 sigmas from mean, p-value= .34619 tst no 10: 141038 missing words, -2.04 sigmas from mean, p-value= .02088 tst no 11: 141458 missing words, -1.05 sigmas from mean, p-value= .14583 tst no 12: 142105 missing words, .46 sigmas from mean, p-value= .67623 tst no 13: 142446 missing words, 1.25 sigmas from mean, p-value= .89506 tst no 14: 142663 missing words, 1.76 sigmas from mean, p-value= .96087 tst no 15: 141474 missing words, -1.02 sigmas from mean, p-value= .15455 tst no 16: 141587 missing words, -.75 sigmas from mean, p-value= .22569 tst no 17: 142107 missing words, .46 sigmas from mean, p-value= .67791 tst no 18: 141212 missing words, -1.63 sigmas from mean, p-value= .05163 tst no 19: 142029 missing words, .28 sigmas from mean, p-value= .61011 tst no 20: 141304 missing words, -1.41 sigmas from mean, p-value= .07863 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 random.dat Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OPSO for random.dat using bits 23 to 32 142366 1.575 .9423 OPSO for random.dat using bits 22 to 31 142482 1.975 .9759 OPSO for random.dat using bits 21 to 30 141831 -.270 .3935 OPSO for random.dat using bits 20 to 29 141843 -.229 .4095 OPSO for random.dat using bits 19 to 28 142260 1.209 .8867 OPSO for random.dat using bits 18 to 27 141730 -.618 .2682 OPSO for random.dat using bits 17 to 26 141842 -.232 .4082 OPSO for random.dat using bits 16 to 25 142122 .733 .7683 OPSO for random.dat using bits 15 to 24 141680 -.791 .2145 OPSO for random.dat using bits 14 to 23 141615 -1.015 .1551 OPSO for random.dat using bits 13 to 22 142137 .785 .7838 OPSO for random.dat using bits 12 to 21 142350 1.520 .9357 OPSO for random.dat using bits 11 to 20 142398 1.685 .9540 OPSO for random.dat using bits 10 to 19 141824 -.294 .3843 OPSO for random.dat using bits 9 to 18 141683 -.780 .2176 OPSO for random.dat using bits 8 to 17 141626 -.977 .1643 OPSO for random.dat using bits 7 to 16 141688 -.763 .2227 OPSO for random.dat using bits 6 to 15 142304 1.361 .9132 OPSO for random.dat using bits 5 to 14 141910 .002 .5009 OPSO for random.dat using bits 4 to 13 142047 .475 .6825 OPSO for random.dat using bits 3 to 12 141994 .292 .6148 OPSO for random.dat using bits 2 to 11 141994 .292 .6148 OPSO for random.dat using bits 1 to 10 141977 .233 .5923 OQSO test for generator random.dat Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OQSO for random.dat using bits 28 to 32 141646 -.893 .1860 OQSO for random.dat using bits 27 to 31 141781 -.435 .3318 OQSO for random.dat using bits 26 to 30 142115 .697 .7572 OQSO for random.dat using bits 25 to 29 141342 -1.923 .0272 OQSO for random.dat using bits 24 to 28 141915 .019 .5077 OQSO for random.dat using bits 23 to 27 141874 -.120 .4523 OQSO for random.dat using bits 22 to 26 142181 .921 .8215 OQSO for random.dat using bits 21 to 25 141884 -.086 .4658 OQSO for random.dat using bits 20 to 24 142018 .368 .6437 OQSO for random.dat using bits 19 to 23 142130 .748 .7728 OQSO for random.dat using bits 18 to 22 141570 -1.150 .1250 OQSO for random.dat using bits 17 to 21 141794 -.391 .3479 OQSO for random.dat using bits 16 to 20 142430 1.765 .9612 OQSO for random.dat using bits 15 to 19 142146 .802 .7888 OQSO for random.dat using bits 14 to 18 142000 .307 .6207 OQSO for random.dat using bits 13 to 17 141484 -1.442 .0747 OQSO for random.dat using bits 12 to 16 142099 .643 .7399 OQSO for random.dat using bits 11 to 15 142066 .531 .7023 OQSO for random.dat using bits 10 to 14 141244 -2.255 .0121 OQSO for random.dat using bits 9 to 13 141545 -1.235 .1084 OQSO for random.dat using bits 8 to 12 142461 1.870 .9693 OQSO for random.dat using bits 7 to 11 142157 .840 .7994 OQSO for random.dat using bits 6 to 10 142646 2.497 .9937 OQSO for random.dat using bits 5 to 9 141609 -1.018 .1543 OQSO for random.dat using bits 4 to 8 141440 -1.591 .0558 OQSO for random.dat using bits 3 to 7 142080 .579 .7186 OQSO for random.dat using bits 2 to 6 141649 -.882 .1888 OQSO for random.dat using bits 1 to 5 141494 -1.408 .0796 DNA test for generator random.dat Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p DNA for random.dat using bits 31 to 32 142174 .781 .7825 DNA for random.dat using bits 30 to 31 141385 -1.547 .0610 DNA for random.dat using bits 29 to 30 142113 .601 .7260 DNA for random.dat using bits 28 to 29 142271 1.067 .8570 DNA for random.dat using bits 27 to 28 141625 -.839 .2008 DNA for random.dat using bits 26 to 27 141785 -.367 .3569 DNA for random.dat using bits 25 to 26 142001 .270 .6066 DNA for random.dat using bits 24 to 25 141807 -.302 .3814 DNA for random.dat using bits 23 to 24 142075 .489 .6875 DNA for random.dat using bits 22 to 23 141840 -.205 .4190 DNA for random.dat using bits 21 to 22 142202 .863 .8060 DNA for random.dat using bits 20 to 21 141408 -1.479 .0696 DNA for random.dat using bits 19 to 20 141915 .017 .5067 DNA for random.dat using bits 18 to 19 142179 .795 .7868 DNA for random.dat using bits 17 to 18 142084 .515 .6968 DNA for random.dat using bits 16 to 17 142754 2.492 .9936 DNA for random.dat using bits 15 to 16 142306 1.170 .8790 DNA for random.dat using bits 14 to 15 141635 -.809 .2092 DNA for random.dat using bits 13 to 14 142265 1.049 .8530 DNA for random.dat using bits 12 to 13 142211 .890 .8132 DNA for random.dat using bits 11 to 12 142043 .394 .6533 DNA for random.dat using bits 10 to 11 141957 .141 .5559 DNA for random.dat using bits 9 to 10 142171 .772 .7799 DNA for random.dat using bits 8 to 9 142100 .562 .7131 DNA for random.dat using bits 7 to 8 141290 -1.827 .0339 DNA for random.dat using bits 6 to 7 142225 .931 .8241 DNA for random.dat using bits 5 to 6 141524 -1.137 .1278 DNA for random.dat using bits 4 to 5 141881 -.084 .4667 DNA for random.dat using bits 3 to 4 141657 -.744 .2283 DNA for random.dat using bits 2 to 3 141808 -.299 .3825 DNA for random.dat using bits 1 to 2 141458 -1.331 .0915 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 random.dat 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 random.dat 2576.68 1.084 .860913 byte stream for random.dat 2539.32 .556 .710926 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 2615.77 1.637 .949207 bits 2 to 9 2491.84 -.115 .454078 bits 3 to 10 2548.83 .691 .755074 bits 4 to 11 2626.87 1.794 .963614 bits 5 to 12 2414.06 -1.215 .112108 bits 6 to 13 2407.82 -1.304 .096193 bits 7 to 14 2552.85 .747 .772579 bits 8 to 15 2502.79 .039 .515724 bits 9 to 16 2534.64 .490 .687873 bits 10 to 17 2391.23 -1.538 .062002 bits 11 to 18 2484.50 -.219 .413235 bits 12 to 19 2566.05 .934 .824859 bits 13 to 20 2440.88 -.836 .201565 bits 14 to 21 2453.17 -.662 .253907 bits 15 to 22 2500.57 .008 .503217 bits 16 to 23 2604.78 1.482 .930801 bits 17 to 24 2553.11 .751 .773720 bits 18 to 25 2555.20 .781 .782511 bits 19 to 26 2559.64 .843 .800507 bits 20 to 27 2544.24 .626 .734232 bits 21 to 28 2633.85 1.893 .970817 bits 22 to 29 2469.72 -.428 .334235 bits 23 to 30 2483.56 -.233 .408053 bits 24 to 31 2560.30 .853 .803117 bits 25 to 32 2503.64 .051 .520520 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 random.dat Of 12,000 tries, the average no. of successes should be 3523 with sigma=21.9 Successes: 3538 z-score: .685 p-value: .753306 Successes: 3545 z-score: 1.005 p-value: .842447 Successes: 3530 z-score: .320 p-value: .625377 Successes: 3547 z-score: 1.096 p-value: .863437 Successes: 3514 z-score: -.411 p-value: .340551 Successes: 3506 z-score: -.776 p-value: .218799 Successes: 3530 z-score: .320 p-value: .625377 Successes: 3515 z-score: -.365 p-value: .357445 Successes: 3518 z-score: -.228 p-value: .409702 Successes: 3512 z-score: -.502 p-value: .307734 square size avg. no. parked sample sigma 100. 3525.500 13.804 KSTEST for the above 10: p= .339929 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 random.dat Sample no. d^2 avg equiv uni 5 .8148 .9691 .559060 10 1.7924 .8245 .834939 15 .9700 .8128 .622761 20 2.6815 .9444 .932457 25 1.4711 .9815 .772028 30 .9798 .9421 .626471 35 .3311 .9440 .283047 40 .1495 .8938 .139500 45 .1845 .9394 .169277 50 1.8038 .9019 .836819 55 .6376 .8569 .473116 60 .4809 .8255 .383261 65 .6918 .8294 .501076 70 1.4957 .8418 .777591 75 .2514 .8298 .223268 80 1.7976 .8426 .835794 85 .2398 .8305 .214163 90 1.0032 .8691 .635155 95 .2490 .8821 .221421 100 .0044 .8640 .004380 MINIMUM DISTANCE TEST for random.dat Result of KS test on 20 transformed mindist^2's: p-value= .437482 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 random.dat sample no: 1 r^3= .847 p-value= .02784 sample no: 2 r^3= 34.733 p-value= .68581 sample no: 3 r^3= 35.841 p-value= .69720 sample no: 4 r^3= 26.706 p-value= .58943 sample no: 5 r^3= 2.381 p-value= .07630 sample no: 6 r^3= 22.542 p-value= .52829 sample no: 7 r^3= .804 p-value= .02643 sample no: 8 r^3= 27.644 p-value= .60207 sample no: 9 r^3= 41.702 p-value= .75094 sample no: 10 r^3= 17.544 p-value= .44278 sample no: 11 r^3= 3.779 p-value= .11835 sample no: 12 r^3= 4.251 p-value= .13212 sample no: 13 r^3= 20.886 p-value= .50152 sample no: 14 r^3= .844 p-value= .02774 sample no: 15 r^3= 32.726 p-value= .66408 sample no: 16 r^3= 77.524 p-value= .92454 sample no: 17 r^3= 16.808 p-value= .42894 sample no: 18 r^3= 15.189 p-value= .39728 sample no: 19 r^3= 2.367 p-value= .07587 sample no: 20 r^3= 144.360 p-value= .99187 A KS test is applied to those 20 p-values. --------------------------------------------------------- 3DSPHERES test for file random.dat p-value= .781459 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 random.dat Table of standardized frequency counts ( (obs-exp)/sqrt(exp) )^2 for j taking values <=6,7,8,...,47,>=48: 2.0 -.3 .8 1.2 -.4 1.4 1.0 -.1 .3 -1.7 -.5 .2 -.4 -.1 -.1 .2 .4 -1.8 .3 .0 -1.1 .2 1.6 .6 -.5 .9 1.6 .0 -1.3 .9 1.3 -.7 2.4 -.5 -1.3 -.8 .5 1.8 -2.0 -.7 -1.3 .0 -.1 Chi-square with 42 degrees of freedom: 46.905 z-score= .535 p-value= .721833 ______________________________________________________________ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 .882079 Test no. 2 p-value .049413 Test no. 3 p-value .865888 Test no. 4 p-value .510375 Test no. 5 p-value .181257 Test no. 6 p-value .830493 Test no. 7 p-value .147783 Test no. 8 p-value .966402 Test no. 9 p-value .969545 Test no. 10 p-value .359790 Results of the OSUM test for random.dat KSTEST on the above 10 p-values: .739630 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 random.dat Up and down runs in a sample of 10000 _________________________________________________ Run test for random.dat : runs up; ks test for 10 p's: .772944 runs down; ks test for 10 p's: .458053 Run test for random.dat : runs up; ks test for 10 p's: .376628 runs down; ks test for 10 p's: .148115 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 random.dat No. of wins: Observed Expected 98588 98585.86 98588= No. of wins, z-score= .010 pvalue= .50382 Analysis of Throws-per-Game: Chisq= 21.82 for 20 degrees of freedom, p= .64987 Throws Observed Expected Chisq Sum 1 66946 66666.7 1.170 1.170 2 37567 37654.3 .203 1.373 3 26824 26954.7 .634 2.007 4 19392 19313.5 .319 2.326 5 13901 13851.4 .177 2.504 6 9912 9943.5 .100 2.604 7 6939 7145.0 5.941 8.545 8 5067 5139.1 1.011 9.555 9 3702 3699.9 .001 9.556 10 2719 2666.3 1.042 10.598 11 1910 1923.3 .092 10.691 12 1457 1388.7 3.355 14.046 13 974 1003.7 .880 14.925 14 720 726.1 .052 14.977 15 545 525.8 .698 15.676 16 361 381.2 1.065 16.741 17 287 276.5 .396 17.137 18 229 200.8 3.951 21.088 19 145 146.0 .007 21.095 20 115 106.2 .727 21.821 21 288 287.1 .003 21.824 SUMMARY FOR random.dat p-value for no. of wins: .503819 p-value for throws/game: .649871 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Results of DIEHARD battery of tests sent to file diehard.out