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.bin For a sample of size 500: mean ..\random.bin using bits 1 to 24 1.952 duplicate number number spacings observed expected 0 77. 67.668 1 125. 135.335 2 140. 135.335 3 91. 90.224 4 44. 45.112 5 19. 18.045 6 to INF 4. 8.282 Chisquare with 6 d.o.f. = 4.54 p-value= .395398 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean ..\random.bin using bits 2 to 25 2.040 duplicate number number spacings observed expected 0 63. 67.668 1 130. 135.335 2 142. 135.335 3 90. 90.224 4 49. 45.112 5 20. 18.045 6 to INF 6. 8.282 Chisquare with 6 d.o.f. = 2.04 p-value= .083713 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean ..\random.bin using bits 3 to 26 2.048 duplicate number number spacings observed expected 0 64. 67.668 1 140. 135.335 2 127. 135.335 3 93. 90.224 4 41. 45.112 5 26. 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.bin using bits 4 to 27 2.082 duplicate number number spacings observed expected 0 69. 67.668 1 117. 135.335 2 135. 135.335 3 99. 90.224 4 51. 45.112 5 21. 18.045 6 to INF 8. 8.282 Chisquare with 6 d.o.f. = 4.63 p-value= .407542 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean ..\random.bin using bits 5 to 28 2.216 duplicate number number spacings observed expected 0 56. 67.668 1 113. 135.335 2 137. 135.335 3 101. 90.224 4 59. 45.112 5 24. 18.045 6 to INF 10. 8.282 Chisquare with 6 d.o.f. = 13.60 p-value= .965603 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean ..\random.bin using bits 6 to 29 2.022 duplicate number number spacings observed expected 0 57. 67.668 1 141. 135.335 2 140. 135.335 3 96. 90.224 4 39. 45.112 5 18. 18.045 6 to INF 9. 8.282 Chisquare with 6 d.o.f. = 3.34 p-value= .234862 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean ..\random.bin using bits 7 to 30 2.042 duplicate number number spacings observed expected 0 55. 67.668 1 142. 135.335 2 136. 135.335 3 100. 90.224 4 38. 45.112 5 21. 18.045 6 to INF 8. 8.282 Chisquare with 6 d.o.f. = 5.38 p-value= .503557 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean ..\random.bin using bits 8 to 31 2.026 duplicate number number spacings observed expected 0 72. 67.668 1 133. 135.335 2 121. 135.335 3 98. 90.224 4 52. 45.112 5 14. 18.045 6 to INF 10. 8.282 Chisquare with 6 d.o.f. = 4.82 p-value= .433066 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean ..\random.bin using bits 9 to 32 2.044 duplicate number number spacings observed expected 0 67. 67.668 1 140. 135.335 2 119. 135.335 3 100. 90.224 4 44. 45.112 5 19. 18.045 6 to INF 11. 8.282 Chisquare with 6 d.o.f. = 4.17 p-value= .346122 ::::::::::::::::::::::::::::::::::::::::: The 9 p-values were .395398 .083713 .443642 .407542 .965603 .234862 .503557 .433066 .346122 A KSTEST for the 9 p-values yields .696582 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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.bin For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom= 84.149; p-value= .143284 OPERM5 test for file ..\random.bin For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom= 73.572; p-value= .026121 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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.bin Rank test for 31x31 binary matrices: rows from leftmost 31 bits of each 32-bit integer rank observed expected (o-e)^2/e sum 28 191 211.4 1.971901 1.972 29 5236 5134.0 2.026079 3.998 30 23027 23103.0 .250319 4.248 31 11546 11551.5 .002642 4.251 chisquare= 4.251 for 3 d. of f.; p-value= .784003 -------------------------------------------------------------- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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.bin Rank test for 32x32 binary matrices: rows from leftmost 32 bits of each 32-bit integer rank observed expected (o-e)^2/e sum 29 209 211.4 .027655 .028 30 5170 5134.0 .252290 .280 31 22995 23103.0 .505307 .785 32 11626 11551.5 .480163 1.265 chisquare= 1.265 for 3 d. of f.; p-value= .392953 -------------------------------------------------------------- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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.bin Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 1 to 8 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 914 944.3 .972 .972 r =5 21482 21743.9 3.155 4.127 r =6 77604 77311.8 1.104 5.231 p=1-exp(-SUM/2)= .92688 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 2 to 9 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 907 944.3 1.473 1.473 r =5 21459 21743.9 3.733 5.206 r =6 77634 77311.8 1.343 6.549 p=1-exp(-SUM/2)= .96217 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 3 to 10 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 938 944.3 .042 .042 r =5 21359 21743.9 6.813 6.855 r =6 77703 77311.8 1.979 8.835 p=1-exp(-SUM/2)= .98793 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 4 to 11 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 951 944.3 .048 .048 r =5 21530 21743.9 2.104 2.152 r =6 77519 77311.8 .555 2.707 p=1-exp(-SUM/2)= .74166 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 5 to 12 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 899 944.3 2.173 2.173 r =5 21316 21743.9 8.421 10.594 r =6 77785 77311.8 2.896 13.490 p=1-exp(-SUM/2)= .99882 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 6 to 13 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 915 944.3 .909 .909 r =5 21371 21743.9 6.395 7.304 r =6 77714 77311.8 2.092 9.397 p=1-exp(-SUM/2)= .99089 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 7 to 14 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 864 944.3 6.829 6.829 r =5 21412 21743.9 5.066 11.895 r =6 77724 77311.8 2.198 14.092 p=1-exp(-SUM/2)= .99913 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 8 to 15 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 862 944.3 7.173 7.173 r =5 21583 21743.9 1.191 8.364 r =6 77555 77311.8 .765 9.129 p=1-exp(-SUM/2)= .98958 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 9 to 16 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 925 944.3 .395 .395 r =5 21446 21743.9 4.081 4.476 r =6 77629 77311.8 1.301 5.777 p=1-exp(-SUM/2)= .94435 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 10 to 17 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 897 944.3 2.369 2.369 r =5 21330 21743.9 7.879 10.248 r =6 77773 77311.8 2.751 12.999 p=1-exp(-SUM/2)= .99850 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 11 to 18 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 855 944.3 8.445 8.445 r =5 21437 21743.9 4.332 12.777 r =6 77708 77311.8 2.030 14.807 p=1-exp(-SUM/2)= .99939 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 12 to 19 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 921 944.3 .575 .575 r =5 21393 21743.9 5.663 6.238 r =6 77686 77311.8 1.811 8.049 p=1-exp(-SUM/2)= .98213 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 13 to 20 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 900 944.3 2.078 2.078 r =5 21354 21743.9 6.991 9.070 r =6 77746 77311.8 2.439 11.508 p=1-exp(-SUM/2)= .99683 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 14 to 21 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 897 944.3 2.369 2.369 r =5 21494 21743.9 2.872 5.241 r =6 77609 77311.8 1.142 6.384 p=1-exp(-SUM/2)= .95891 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 15 to 22 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 929 944.3 .248 .248 r =5 21538 21743.9 1.950 2.198 r =6 77533 77311.8 .633 2.831 p=1-exp(-SUM/2)= .75714 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 16 to 23 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 959 944.3 .229 .229 r =5 21350 21743.9 7.136 7.364 r =6 77691 77311.8 1.860 9.224 p=1-exp(-SUM/2)= .99007 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 17 to 24 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 910 944.3 1.246 1.246 r =5 21301 21743.9 9.021 10.267 r =6 77789 77311.8 2.945 13.213 p=1-exp(-SUM/2)= .99865 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 18 to 25 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 937 944.3 .056 .056 r =5 21660 21743.9 .324 .380 r =6 77403 77311.8 .108 .488 p=1-exp(-SUM/2)= .21642 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 19 to 26 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 920 944.3 .625 .625 r =5 21491 21743.9 2.941 3.567 r =6 77589 77311.8 .994 4.561 p=1-exp(-SUM/2)= .89775 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 20 to 27 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 933 944.3 .135 .135 r =5 21600 21743.9 .952 1.088 r =6 77467 77311.8 .312 1.399 p=1-exp(-SUM/2)= .50320 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 21 to 28 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 918 944.3 .733 .733 r =5 21345 21743.9 7.318 8.051 r =6 77737 77311.8 2.338 10.389 p=1-exp(-SUM/2)= .99445 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 22 to 29 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 876 944.3 4.940 4.940 r =5 21437 21743.9 4.332 9.272 r =6 77687 77311.8 1.821 11.093 p=1-exp(-SUM/2)= .99610 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 23 to 30 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 886 944.3 3.600 3.600 r =5 21512 21743.9 2.473 6.073 r =6 77602 77311.8 1.089 7.162 p=1-exp(-SUM/2)= .97215 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 24 to 31 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 957 944.3 .171 .171 r =5 21538 21743.9 1.950 2.121 r =6 77505 77311.8 .483 2.603 p=1-exp(-SUM/2)= .72792 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG ..\random.bin b-rank test for bits 25 to 32 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 894 944.3 2.679 2.679 r =5 21541 21743.9 1.893 4.573 r =6 77565 77311.8 .829 5.402 p=1-exp(-SUM/2)= .93286 TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices These should be 25 uniform [0,1] random variables: .926876 .962166 .987935 .741665 .998823 .990889 .999129 .989583 .944348 .998496 .999391 .982127 .996831 .958909 .757140 .990070 .998648 .216419 .897751 .503196 .994453 .996098 .972153 .727916 .932862 brank test summary for ..\random.bin The KS test for those 25 supposed UNI's yields KS p-value=1.000000 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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: 145437 missing words, 8.24 sigmas from mean, p-value=1.00000 tst no 2: 145740 missing words, 8.95 sigmas from mean, p-value=1.00000 tst no 3: 145415 missing words, 8.19 sigmas from mean, p-value=1.00000 tst no 4: 144909 missing words, 7.01 sigmas from mean, p-value=1.00000 tst no 5: 146053 missing words, 9.68 sigmas from mean, p-value=1.00000 tst no 6: 146216 missing words, 10.06 sigmas from mean, p-value=1.00000 tst no 7: 145979 missing words, 9.51 sigmas from mean, p-value=1.00000 tst no 8: 145719 missing words, 8.90 sigmas from mean, p-value=1.00000 tst no 9: 146110 missing words, 9.81 sigmas from mean, p-value=1.00000 tst no 10: 146027 missing words, 9.62 sigmas from mean, p-value=1.00000 tst no 11: 145661 missing words, 8.77 sigmas from mean, p-value=1.00000 tst no 12: 146305 missing words, 10.27 sigmas from mean, p-value=1.00000 tst no 13: 145610 missing words, 8.65 sigmas from mean, p-value=1.00000 tst no 14: 146544 missing words, 10.83 sigmas from mean, p-value=1.00000 tst no 15: 146261 missing words, 10.17 sigmas from mean, p-value=1.00000 tst no 16: 146132 missing words, 9.87 sigmas from mean, p-value=1.00000 tst no 17: 145188 missing words, 7.66 sigmas from mean, p-value=1.00000 tst no 18: 146050 missing words, 9.67 sigmas from mean, p-value=1.00000 tst no 19: 146576 missing words, 10.90 sigmas from mean, p-value=1.00000 tst no 20: 146405 missing words, 10.50 sigmas from mean, p-value=1.00000 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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.bin Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OPSO for ..\random.bin using bits 23 to 32 147351 18.764 1.0000 OPSO for ..\random.bin using bits 22 to 31 146605 16.192 1.0000 OPSO for ..\random.bin using bits 21 to 30 146117 14.509 1.0000 OPSO for ..\random.bin using bits 20 to 29 147701 19.971 1.0000 OPSO for ..\random.bin using bits 19 to 28 146930 17.313 1.0000 OPSO for ..\random.bin using bits 18 to 27 147302 18.595 1.0000 OPSO for ..\random.bin using bits 17 to 26 147122 17.975 1.0000 OPSO for ..\random.bin using bits 16 to 25 145955 13.951 1.0000 OPSO for ..\random.bin using bits 15 to 24 146499 15.826 1.0000 OPSO for ..\random.bin using bits 14 to 23 146153 14.633 1.0000 OPSO for ..\random.bin using bits 13 to 22 145896 13.747 1.0000 OPSO for ..\random.bin using bits 12 to 21 147409 18.964 1.0000 OPSO for ..\random.bin using bits 11 to 20 146117 14.509 1.0000 OPSO for ..\random.bin using bits 10 to 19 147010 17.589 1.0000 OPSO for ..\random.bin using bits 9 to 18 147167 18.130 1.0000 OPSO for ..\random.bin using bits 8 to 17 145867 13.647 1.0000 OPSO for ..\random.bin using bits 7 to 16 146934 17.326 1.0000 OPSO for ..\random.bin using bits 6 to 15 146434 15.602 1.0000 OPSO for ..\random.bin using bits 5 to 14 146608 16.202 1.0000 OPSO for ..\random.bin using bits 4 to 13 147723 20.047 1.0000 OPSO for ..\random.bin using bits 3 to 12 146798 16.857 1.0000 OPSO for ..\random.bin using bits 2 to 11 146928 17.306 1.0000 OPSO for ..\random.bin using bits 1 to 10 146737 16.647 1.0000 OQSO test for generator ..\random.bin Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OQSO for ..\random.bin using bits 28 to 32 147398 18.606 1.0000 OQSO for ..\random.bin using bits 27 to 31 145687 12.806 1.0000 OQSO for ..\random.bin using bits 26 to 30 146065 14.087 1.0000 OQSO for ..\random.bin using bits 25 to 29 146490 15.528 1.0000 OQSO for ..\random.bin using bits 24 to 28 144934 10.253 1.0000 OQSO for ..\random.bin using bits 23 to 27 146442 15.365 1.0000 OQSO for ..\random.bin using bits 22 to 26 146128 14.301 1.0000 OQSO for ..\random.bin using bits 21 to 25 145432 11.941 1.0000 OQSO for ..\random.bin using bits 20 to 24 147401 18.616 1.0000 OQSO for ..\random.bin using bits 19 to 23 145778 13.114 1.0000 OQSO for ..\random.bin using bits 18 to 22 146008 13.894 1.0000 OQSO for ..\random.bin using bits 17 to 21 146882 16.857 1.0000 OQSO for ..\random.bin using bits 16 to 20 145218 11.216 1.0000 OQSO for ..\random.bin using bits 15 to 19 146813 16.623 1.0000 OQSO for ..\random.bin using bits 14 to 18 146150 14.375 1.0000 OQSO for ..\random.bin using bits 13 to 17 145296 11.480 1.0000 OQSO for ..\random.bin using bits 12 to 16 147419 18.677 1.0000 OQSO for ..\random.bin using bits 11 to 15 146052 14.043 1.0000 OQSO for ..\random.bin using bits 10 to 14 146173 14.453 1.0000 OQSO for ..\random.bin using bits 9 to 13 147331 18.379 1.0000 OQSO for ..\random.bin using bits 8 to 12 145290 11.460 1.0000 OQSO for ..\random.bin using bits 7 to 11 146711 16.277 1.0000 OQSO for ..\random.bin using bits 6 to 10 146234 14.660 1.0000 OQSO for ..\random.bin using bits 5 to 9 145096 10.802 1.0000 OQSO for ..\random.bin using bits 4 to 8 147049 17.423 1.0000 OQSO for ..\random.bin using bits 3 to 7 146021 13.938 1.0000 OQSO for ..\random.bin using bits 2 to 6 146251 14.718 1.0000 OQSO for ..\random.bin using bits 1 to 5 147394 18.592 1.0000 DNA test for generator ..\random.bin Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p DNA for ..\random.bin using bits 31 to 32 146694 14.114 1.0000 DNA for ..\random.bin using bits 30 to 31 143834 5.677 1.0000 DNA for ..\random.bin using bits 29 to 30 143429 4.483 1.0000 DNA for ..\random.bin using bits 28 to 29 147184 15.560 1.0000 DNA for ..\random.bin using bits 27 to 28 142556 1.908 .9718 DNA for ..\random.bin using bits 26 to 27 144388 7.312 1.0000 DNA for ..\random.bin using bits 25 to 26 145739 11.297 1.0000 DNA for ..\random.bin using bits 24 to 25 142048 .409 .6588 DNA for ..\random.bin using bits 23 to 24 145802 11.483 1.0000 DNA for ..\random.bin using bits 22 to 23 144080 6.403 1.0000 DNA for ..\random.bin using bits 21 to 22 143579 4.925 1.0000 DNA for ..\random.bin using bits 20 to 21 147518 16.545 1.0000 DNA for ..\random.bin using bits 19 to 20 142986 3.176 .9993 DNA for ..\random.bin using bits 18 to 19 144214 6.798 1.0000 DNA for ..\random.bin using bits 17 to 18 145590 10.857 1.0000 DNA for ..\random.bin using bits 16 to 17 141748 -.476 .3171 DNA for ..\random.bin using bits 15 to 16 146453 13.403 1.0000 DNA for ..\random.bin using bits 14 to 15 143745 5.415 1.0000 DNA for ..\random.bin using bits 13 to 14 143613 5.026 1.0000 DNA for ..\random.bin using bits 12 to 13 147204 15.619 1.0000 DNA for ..\random.bin using bits 11 to 12 143104 3.524 .9998 DNA for ..\random.bin using bits 10 to 11 144062 6.350 1.0000 DNA for ..\random.bin using bits 9 to 10 145685 11.138 1.0000 DNA for ..\random.bin using bits 8 to 9 141724 -.547 .2923 DNA for ..\random.bin using bits 7 to 8 146018 12.120 1.0000 DNA for ..\random.bin using bits 6 to 7 143813 5.616 1.0000 DNA for ..\random.bin using bits 5 to 6 143534 4.793 1.0000 DNA for ..\random.bin using bits 4 to 5 147454 16.356 1.0000 DNA for ..\random.bin using bits 3 to 4 142547 1.881 .9700 DNA for ..\random.bin using bits 2 to 3 144639 8.052 1.0000 DNA for ..\random.bin using bits 1 to 2 146623 13.905 1.0000 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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.bin Chi-square with 5^5-5^4=2500 d.of f. for sample size:2560000 chisquare equiv normal p-value Results fo COUNT-THE-1's in successive bytes: byte stream for ..\random.bin 5417.24 41.256 1.000000 byte stream for ..\random.bin 5830.22 47.096 1.000000 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 2638.23 1.955 .974701 bits 2 to 9 2678.34 2.522 .994168 bits 3 to 10 2702.30 2.861 .997889 bits 4 to 11 2645.78 2.062 .980382 bits 5 to 12 2638.82 1.963 .975190 bits 6 to 13 2766.53 3.769 .999918 bits 7 to 14 2659.38 2.254 .987902 bits 8 to 15 2695.22 2.761 .997117 bits 9 to 16 2807.84 4.353 .999993 bits 10 to 17 2623.49 1.746 .959625 bits 11 to 18 2761.97 3.705 .999894 bits 12 to 19 2756.78 3.631 .999859 bits 13 to 20 2637.83 1.949 .974366 bits 14 to 21 2623.79 1.751 .960001 bits 15 to 22 2718.60 3.092 .999004 bits 16 to 23 2586.20 1.219 .888589 bits 17 to 24 2531.83 .450 .673691 bits 18 to 25 2576.92 1.088 .861656 bits 19 to 26 2605.61 1.494 .932361 bits 20 to 27 2648.02 2.093 .981840 bits 21 to 28 2538.72 .548 .707994 bits 22 to 29 2516.54 .234 .592467 bits 23 to 30 2646.32 2.069 .980739 bits 24 to 31 2520.51 .290 .614099 bits 25 to 32 2678.93 2.530 .994304 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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.bin Of 12,000 tries, the average no. of successes should be 3523 with sigma=21.9 Successes: 3557 z-score: 1.553 p-value: .939730 Successes: 3507 z-score: -.731 p-value: .232514 Successes: 3525 z-score: .091 p-value: .536382 Successes: 3482 z-score: -1.872 p-value: .030593 Successes: 3521 z-score: -.091 p-value: .463618 Successes: 3502 z-score: -.959 p-value: .168804 Successes: 3509 z-score: -.639 p-value: .261324 Successes: 3507 z-score: -.731 p-value: .232514 Successes: 3486 z-score: -1.689 p-value: .045562 Successes: 3497 z-score: -1.187 p-value: .117571 square size avg. no. parked sample sigma 100. 3509.300 20.374 KSTEST for the above 10: p= .961656 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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.bin Sample no. d^2 avg equiv uni 5 .0928 .6032 .089048 10 .1508 .7132 .140639 15 .3330 .7269 .284407 20 1.1581 .7470 .687756 25 .5502 .7178 .424779 30 .3628 .7459 .305528 35 1.1737 .8296 .692591 40 .0420 .9201 .041319 45 .0515 .9112 .050482 50 1.2684 .8888 .720516 55 .2508 .8655 .222787 60 .7502 .8553 .529509 65 .6119 .8324 .459359 70 .6470 .9054 .478078 75 .3737 .8746 .313109 80 .7777 .8764 .542336 85 2.0282 .8749 .869756 90 .0618 .8607 .060238 95 1.0969 .8426 .667921 100 .3450 .8745 .293007 MINIMUM DISTANCE TEST for ..\random.bin Result of KS test on 20 transformed mindist^2's: p-value= .875022 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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.bin sample no: 1 r^3= 10.908 p-value= .30483 sample no: 2 r^3= 47.315 p-value= .79344 sample no: 3 r^3= 32.861 p-value= .66559 sample no: 4 r^3= 12.126 p-value= .33249 sample no: 5 r^3= 4.815 p-value= .14829 sample no: 6 r^3= 6.216 p-value= .18713 sample no: 7 r^3= 28.974 p-value= .61932 sample no: 8 r^3= 16.181 p-value= .41687 sample no: 9 r^3= 5.600 p-value= .17028 sample no: 10 r^3= 18.161 p-value= .45412 sample no: 11 r^3= 10.657 p-value= .29900 sample no: 12 r^3= 23.558 p-value= .54401 sample no: 13 r^3= 30.195 p-value= .63450 sample no: 14 r^3= 24.733 p-value= .56152 sample no: 15 r^3= 12.186 p-value= .33382 sample no: 16 r^3= 7.857 p-value= .23040 sample no: 17 r^3= 55.641 p-value= .84350 sample no: 18 r^3= 36.073 p-value= .69954 sample no: 19 r^3= 13.829 p-value= .36932 sample no: 20 r^3= 87.284 p-value= .94549 A KS test is applied to those 20 p-values. --------------------------------------------------------- 3DSPHERES test for file ..\random.bin p-value= .495451 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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.bin Table of standardized frequency counts ( (obs-exp)/sqrt(exp) )^2 for j taking values <=6,7,8,...,47,>=48: -.8 -1.2 -.8 -.4 -2.4 -.8 -1.3 .4 -.9 -.9 1.6 -.5 1.2 2.6 1.2 2.4 -.2 1.4 -.9 -.4 -.2 -.4 -.9 -.5 -2.9 -2.1 -.3 -.2 -2.1 -.6 -1.1 -1.2 .4 -.6 .5 .6 -1.4 -.7 .1 -.7 .9 .0 -.1 Chi-square with 42 degrees of freedom: 59.741 z-score= 1.936 p-value= .962952 ______________________________________________________________ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 .508706 Test no. 2 p-value .958224 Test no. 3 p-value .352547 Test no. 4 p-value .661552 Test no. 5 p-value .426788 Test no. 6 p-value .644902 Test no. 7 p-value .174785 Test no. 8 p-value .609439 Test no. 9 p-value .999259 Test no. 10 p-value .775850 Results of the OSUM test for ..\random.bin KSTEST on the above 10 p-values: .772309 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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.bin Up and down runs in a sample of 10000 _________________________________________________ Run test for ..\random.bin : runs up; ks test for 10 p's: .032200 runs down; ks test for 10 p's: .624321 Run test for ..\random.bin : runs up; ks test for 10 p's: .684168 runs down; ks test for 10 p's: .199944 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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.bin No. of wins: Observed Expected 98051 98585.86 98051= No. of wins, z-score=-2.392 pvalue= .00837 Analysis of Throws-per-Game: Chisq= 86.09 for 20 degrees of freedom, p= 1.00000 Throws Observed Expected Chisq Sum 1 68386 66666.7 44.341 44.341 2 36947 37654.3 13.287 57.628 3 26623 26954.7 4.083 61.711 4 19146 19313.5 1.452 63.163 5 13650 13851.4 2.929 66.092 6 9893 9943.5 .257 66.349 7 6984 7145.0 3.629 69.978 8 4992 5139.1 4.209 74.186 9 3581 3699.9 3.819 78.005 10 2724 2666.3 1.249 79.254 11 1897 1923.3 .360 79.614 12 1418 1388.7 .616 80.231 13 1022 1003.7 .333 80.564 14 738 726.1 .194 80.758 15 549 525.8 1.020 81.778 16 399 381.2 .836 82.614 17 287 276.5 .396 83.010 18 195 200.8 .169 83.179 19 163 146.0 1.983 85.162 20 116 106.2 .901 86.064 21 290 287.1 .029 86.093 SUMMARY FOR ..\random.bin p-value for no. of wins: .008374 p-value for throws/game:1.000000 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Results of DIEHARD battery of tests sent to file random.txt