codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
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 bbs.32 For a sample of size 500: mean bbs.32 using bits 1 to 24 1.974 duplicate number number spacings observed expected 0 74. 67.668 1 145. 135.335 2 116. 135.335 3 90. 90.224 4 49. 45.112 5 19. 18.045 6 to INF 7. 8.282 Chisquare with 6 d.o.f. = 4.63 p-value= .407914 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bbs.32 using bits 2 to 25 2.006 duplicate number number spacings observed expected 0 62. 67.668 1 125. 135.335 2 144. 135.335 3 115. 90.224 4 34. 45.112 5 14. 18.045 6 to INF 6. 8.282 Chisquare with 6 d.o.f. = 12.89 p-value= .955266 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bbs.32 using bits 3 to 26 1.952 duplicate number number spacings observed expected 0 74. 67.668 1 139. 135.335 2 130. 135.335 3 91. 90.224 4 43. 45.112 5 13. 18.045 6 to INF 10. 8.282 Chisquare with 6 d.o.f. = 2.77 p-value= .163428 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bbs.32 using bits 4 to 27 2.018 duplicate number number spacings observed expected 0 60. 67.668 1 154. 135.335 2 126. 135.335 3 82. 90.224 4 50. 45.112 5 17. 18.045 6 to INF 11. 8.282 Chisquare with 6 d.o.f. = 6.32 p-value= .611556 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bbs.32 using bits 5 to 28 1.894 duplicate number number spacings observed expected 0 78. 67.668 1 146. 135.335 2 129. 135.335 3 81. 90.224 4 40. 45.112 5 19. 18.045 6 to INF 7. 8.282 Chisquare with 6 d.o.f. = 4.49 p-value= .388760 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bbs.32 using bits 6 to 29 2.098 duplicate number number spacings observed expected 0 52. 67.668 1 137. 135.335 2 132. 135.335 3 101. 90.224 4 51. 45.112 5 22. 18.045 6 to INF 5. 8.282 Chisquare with 6 d.o.f. = 7.95 p-value= .758471 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bbs.32 using bits 7 to 30 1.902 duplicate number number spacings observed expected 0 76. 67.668 1 139. 135.335 2 130. 135.335 3 95. 90.224 4 40. 45.112 5 13. 18.045 6 to INF 7. 8.282 Chisquare with 6 d.o.f. = 3.78 p-value= .293096 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bbs.32 using bits 8 to 31 2.038 duplicate number number spacings observed expected 0 62. 67.668 1 127. 135.335 2 139. 135.335 3 98. 90.224 4 54. 45.112 5 16. 18.045 6 to INF 4. 8.282 Chisquare with 6 d.o.f. = 5.95 p-value= .571665 ::::::::::::::::::::::::::::::::::::::::: For a sample of size 500: mean bbs.32 using bits 9 to 32 1.896 duplicate number number spacings observed expected 0 80. 67.668 1 142. 135.335 2 128. 135.335 3 75. 90.224 4 52. 45.112 5 21. 18.045 6 to INF 2. 8.282 Chisquare with 6 d.o.f. = 11.84 p-value= .934427 ::::::::::::::::::::::::::::::::::::::::: The 9 p-values were .407914 .955266 .163428 .611556 .388760 .758471 .293096 .571665 .934427 A KSTEST for the 9 p-values yields .237399 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bbs.32 For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom=109.577; p-value= .780459 OPERM5 test for file bbs.32 For a sample of 1,000,000 consecutive 5-tuples, chisquare for 99 degrees of freedom= 88.425; p-value= .231897 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bbs.32 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 202 211.4 .419543 .420 29 5040 5134.0 1.721447 2.141 30 23212 23103.0 .513819 2.655 31 11546 11551.5 .002642 2.657 chisquare= 2.657 for 3 d. of f.; p-value= .604027 -------------------------------------------------------------- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bbs.32 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 208 211.4 .055259 .055 30 5111 5134.0 .103130 .158 31 23110 23103.0 .002093 .160 32 11571 11551.5 .032835 .193 chisquare= .193 for 3 d. of f.; p-value= .351424 -------------------------------------------------------------- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bbs.32 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 1 to 8 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 926 944.3 .355 .355 r =5 21903 21743.9 1.164 1.519 r =6 77171 77311.8 .256 1.775 p=1-exp(-SUM/2)= .58837 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 2 to 9 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 992 944.3 2.409 2.409 r =5 21812 21743.9 .213 2.623 r =6 77196 77311.8 .173 2.796 p=1-exp(-SUM/2)= .75292 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 3 to 10 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 905 944.3 1.636 1.636 r =5 21838 21743.9 .407 2.043 r =6 77257 77311.8 .039 2.082 p=1-exp(-SUM/2)= .64686 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 4 to 11 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 961 944.3 .295 .295 r =5 21595 21743.9 1.020 1.315 r =6 77444 77311.8 .226 1.541 p=1-exp(-SUM/2)= .53722 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 5 to 12 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 947 944.3 .008 .008 r =5 21564 21743.9 1.488 1.496 r =6 77489 77311.8 .406 1.902 p=1-exp(-SUM/2)= .61370 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 6 to 13 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 928 944.3 .281 .281 r =5 22065 21743.9 4.742 5.023 r =6 77007 77311.8 1.202 6.225 p=1-exp(-SUM/2)= .95551 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 7 to 14 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 1002 944.3 3.526 3.526 r =5 21898 21743.9 1.092 4.618 r =6 77100 77311.8 .580 5.198 p=1-exp(-SUM/2)= .92565 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 8 to 15 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 919 944.3 .678 .678 r =5 21896 21743.9 1.064 1.742 r =6 77185 77311.8 .208 1.950 p=1-exp(-SUM/2)= .62278 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 9 to 16 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 950 944.3 .034 .034 r =5 21874 21743.9 .778 .813 r =6 77176 77311.8 .239 1.051 p=1-exp(-SUM/2)= .40885 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 10 to 17 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 943 944.3 .002 .002 r =5 21654 21743.9 .372 .373 r =6 77403 77311.8 .108 .481 p=1-exp(-SUM/2)= .21379 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 11 to 18 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 958 944.3 .199 .199 r =5 21628 21743.9 .618 .817 r =6 77414 77311.8 .135 .952 p=1-exp(-SUM/2)= .37861 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 12 to 19 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 936 944.3 .073 .073 r =5 21664 21743.9 .294 .367 r =6 77400 77311.8 .101 .467 p=1-exp(-SUM/2)= .20832 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 13 to 20 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 924 944.3 .436 .436 r =5 21650 21743.9 .406 .842 r =6 77426 77311.8 .169 1.011 p=1-exp(-SUM/2)= .39669 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 14 to 21 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 952 944.3 .063 .063 r =5 21623 21743.9 .672 .735 r =6 77425 77311.8 .166 .901 p=1-exp(-SUM/2)= .36260 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 15 to 22 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 917 944.3 .789 .789 r =5 21920 21743.9 1.426 2.216 r =6 77163 77311.8 .286 2.502 p=1-exp(-SUM/2)= .71377 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 16 to 23 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 935 944.3 .092 .092 r =5 22038 21743.9 3.978 4.069 r =6 77027 77311.8 1.049 5.119 p=1-exp(-SUM/2)= .92264 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 17 to 24 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 946 944.3 .003 .003 r =5 22047 21743.9 4.225 4.228 r =6 77007 77311.8 1.202 5.430 p=1-exp(-SUM/2)= .93379 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 18 to 25 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 1000 944.3 3.285 3.285 r =5 21618 21743.9 .729 4.014 r =6 77382 77311.8 .064 4.078 p=1-exp(-SUM/2)= .86984 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 19 to 26 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 984 944.3 1.669 1.669 r =5 21540 21743.9 1.912 3.581 r =6 77476 77311.8 .349 3.930 p=1-exp(-SUM/2)= .85982 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 20 to 27 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 950 944.3 .034 .034 r =5 21864 21743.9 .663 .698 r =6 77186 77311.8 .205 .902 p=1-exp(-SUM/2)= .36316 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 21 to 28 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 949 944.3 .023 .023 r =5 21781 21743.9 .063 .087 r =6 77270 77311.8 .023 .109 p=1-exp(-SUM/2)= .05318 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 22 to 29 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 962 944.3 .332 .332 r =5 21859 21743.9 .609 .941 r =6 77179 77311.8 .228 1.169 p=1-exp(-SUM/2)= .44265 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 23 to 30 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 1031 944.3 7.960 7.960 r =5 21756 21743.9 .007 7.967 r =6 77213 77311.8 .126 8.093 p=1-exp(-SUM/2)= .98252 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 24 to 31 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 949 944.3 .023 .023 r =5 21858 21743.9 .599 .622 r =6 77193 77311.8 .183 .805 p=1-exp(-SUM/2)= .33125 Rank of a 6x8 binary matrix, rows formed from eight bits of the RNG bbs.32 b-rank test for bits 25 to 32 OBSERVED EXPECTED (O-E)^2/E SUM r<=4 954 944.3 .100 .100 r =5 21757 21743.9 .008 .108 r =6 77289 77311.8 .007 .114 p=1-exp(-SUM/2)= .05552 TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices These should be 25 uniform [0,1] random variables: .588370 .752923 .646859 .537217 .613696 .955508 .925648 .622777 .408848 .213789 .378609 .208317 .396685 .362605 .713771 .922644 .933789 .869845 .859824 .363156 .053176 .442649 .982517 .331246 .055516 brank test summary for bbs.32 The KS test for those 25 supposed UNI's yields KS p-value= .615427 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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: 141553 missing words, -.83 sigmas from mean, p-value= .20255 tst no 2: 141650 missing words, -.61 sigmas from mean, p-value= .27229 tst no 3: 141811 missing words, -.23 sigmas from mean, p-value= .40915 tst no 4: 141774 missing words, -.32 sigmas from mean, p-value= .37593 tst no 5: 141923 missing words, .03 sigmas from mean, p-value= .51274 tst no 6: 141900 missing words, -.02 sigmas from mean, p-value= .49131 tst no 7: 142267 missing words, .84 sigmas from mean, p-value= .79833 tst no 8: 141612 missing words, -.69 sigmas from mean, p-value= .24362 tst no 9: 142282 missing words, .87 sigmas from mean, p-value= .80805 tst no 10: 141521 missing words, -.91 sigmas from mean, p-value= .18212 tst no 11: 141486 missing words, -.99 sigmas from mean, p-value= .16131 tst no 12: 141330 missing words, -1.35 sigmas from mean, p-value= .08794 tst no 13: 141517 missing words, -.92 sigmas from mean, p-value= .17966 tst no 14: 141255 missing words, -1.53 sigmas from mean, p-value= .06316 tst no 15: 141580 missing words, -.77 sigmas from mean, p-value= .22081 tst no 16: 141655 missing words, -.59 sigmas from mean, p-value= .27618 tst no 17: 142142 missing words, .54 sigmas from mean, p-value= .70665 tst no 18: 141852 missing words, -.13 sigmas from mean, p-value= .44672 tst no 19: 142621 missing words, 1.66 sigmas from mean, p-value= .95182 tst no 20: 141397 missing words, -1.20 sigmas from mean, p-value= .11565 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bbs.32 Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OPSO for bbs.32 using bits 23 to 32 786526******* 1.0000 OPSO for bbs.32 using bits 22 to 31 786515******* 1.0000 OPSO for bbs.32 using bits 21 to 30 786497******* 1.0000 OPSO for bbs.32 using bits 20 to 29 786510******* 1.0000 OPSO for bbs.32 using bits 19 to 28 786502******* 1.0000 OPSO for bbs.32 using bits 18 to 27 786517******* 1.0000 OPSO for bbs.32 using bits 17 to 26 786514******* 1.0000 OPSO for bbs.32 using bits 16 to 25 696403******* 1.0000 OPSO for bbs.32 using bits 15 to 24 670688******* 1.0000 OPSO for bbs.32 using bits 14 to 23 786516******* 1.0000 OPSO for bbs.32 using bits 13 to 22 786525******* 1.0000 OPSO for bbs.32 using bits 12 to 21 786511******* 1.0000 OPSO for bbs.32 using bits 11 to 20 786520******* 1.0000 OPSO for bbs.32 using bits 10 to 19 786530******* 1.0000 OPSO for bbs.32 using bits 9 to 18 786525******* 1.0000 OPSO for bbs.32 using bits 8 to 17 533939******* 1.0000 OPSO for bbs.32 using bits 7 to 16 142025 .399 .6550 OPSO for bbs.32 using bits 6 to 15 141952 .147 .5585 OPSO for bbs.32 using bits 5 to 14 142731 2.833 .9977 OPSO for bbs.32 using bits 4 to 13 144030 7.313 1.0000 OPSO for bbs.32 using bits 3 to 12 146989 17.516 1.0000 OPSO for bbs.32 using bits 2 to 11 147959 20.861 1.0000 OPSO for bbs.32 using bits 1 to 10 146192 14.768 1.0000 OQSO test for generator bbs.32 Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p OQSO for bbs.32 using bits 28 to 32 141415 -1.676 .0469 OQSO for bbs.32 using bits 27 to 31 141394 -1.747 .0403 OQSO for bbs.32 using bits 26 to 30 141699 -.713 .2379 OQSO for bbs.32 using bits 25 to 29 142150 .816 .7927 OQSO for bbs.32 using bits 24 to 28 152494 35.880 1.0000 OQSO for bbs.32 using bits 23 to 27 157435 52.629 1.0000 OQSO for bbs.32 using bits 22 to 26 154070 41.223 1.0000 OQSO for bbs.32 using bits 21 to 25 149920 27.155 1.0000 OQSO for bbs.32 using bits 20 to 24 146468 15.453 1.0000 OQSO for bbs.32 using bits 19 to 23 148650 22.850 1.0000 OQSO for bbs.32 using bits 18 to 22 151480 32.443 1.0000 OQSO for bbs.32 using bits 17 to 21 151068 31.046 1.0000 OQSO for bbs.32 using bits 16 to 20 149082 24.314 1.0000 OQSO for bbs.32 using bits 15 to 19 148051 20.819 1.0000 OQSO for bbs.32 using bits 14 to 18 146428 15.318 1.0000 OQSO for bbs.32 using bits 13 to 17 145575 12.426 1.0000 OQSO for bbs.32 using bits 12 to 16 143695 6.053 1.0000 OQSO for bbs.32 using bits 11 to 15 144124 7.507 1.0000 OQSO for bbs.32 using bits 10 to 14 146627 15.992 1.0000 OQSO for bbs.32 using bits 9 to 13 144878 10.063 1.0000 OQSO for bbs.32 using bits 8 to 12 143323 4.792 1.0000 OQSO for bbs.32 using bits 7 to 11 143096 4.023 1.0000 OQSO for bbs.32 using bits 6 to 10 142512 2.043 .9795 OQSO for bbs.32 using bits 5 to 9 142174 .897 .8152 OQSO for bbs.32 using bits 4 to 8 142061 .514 .6964 OQSO for bbs.32 using bits 3 to 7 141386 -1.774 .0380 OQSO for bbs.32 using bits 2 to 6 142256 1.175 .8800 OQSO for bbs.32 using bits 1 to 5 142334 1.440 .9250 DNA test for generator bbs.32 Output: No. missing words (mw), equiv normal variate (z), p-value (p) mw z p DNA for bbs.32 using bits 31 to 32 144116 6.509 1.0000 DNA for bbs.32 using bits 30 to 31 145360 10.179 1.0000 DNA for bbs.32 using bits 29 to 30 150735 26.034 1.0000 DNA for bbs.32 using bits 28 to 29 143966 6.067 1.0000 DNA for bbs.32 using bits 27 to 28 144761 8.412 1.0000 DNA for bbs.32 using bits 26 to 27 147121 15.374 1.0000 DNA for bbs.32 using bits 25 to 26 152718 31.884 1.0000 DNA for bbs.32 using bits 24 to 25 148152 18.415 1.0000 DNA for bbs.32 using bits 23 to 24 143681 5.226 1.0000 DNA for bbs.32 using bits 22 to 23 143434 4.498 1.0000 DNA for bbs.32 using bits 21 to 22 147139 15.427 1.0000 DNA for bbs.32 using bits 20 to 21 143406 4.415 1.0000 DNA for bbs.32 using bits 19 to 20 142923 2.990 .9986 DNA for bbs.32 using bits 18 to 19 143632 5.082 1.0000 DNA for bbs.32 using bits 17 to 18 145788 11.442 1.0000 DNA for bbs.32 using bits 16 to 17 146503 13.551 1.0000 DNA for bbs.32 using bits 15 to 16 142548 1.884 .9702 DNA for bbs.32 using bits 14 to 15 142787 2.589 .9952 DNA for bbs.32 using bits 13 to 14 145713 11.220 1.0000 DNA for bbs.32 using bits 12 to 13 143727 5.362 1.0000 DNA for bbs.32 using bits 11 to 12 143096 3.501 .9998 DNA for bbs.32 using bits 10 to 11 143962 6.055 1.0000 DNA for bbs.32 using bits 9 to 10 144058 6.338 1.0000 DNA for bbs.32 using bits 8 to 9 142138 .675 .7500 DNA for bbs.32 using bits 7 to 8 141548 -1.066 .1432 DNA for bbs.32 using bits 6 to 7 142377 1.380 .9161 DNA for bbs.32 using bits 5 to 6 141811 -.290 .3859 DNA for bbs.32 using bits 4 to 5 142150 .710 .7611 DNA for bbs.32 using bits 3 to 4 141585 -.957 .1694 DNA for bbs.32 using bits 2 to 3 142149 .707 .7602 DNA for bbs.32 using bits 1 to 2 141678 -.682 .2475 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bbs.32 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 bbs.32 368585.00 5177.224 1.000000 byte stream for bbs.32 367294.70 5158.977 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 2594.83 1.341 .910057 bits 2 to 9 2494.66 -.076 .469895 bits 3 to 10 2440.62 -.840 .200517 bits 4 to 11 2457.26 -.604 .272785 bits 5 to 12 2457.20 -.605 .272492 bits 6 to 13 2384.35 -1.636 .050966 bits 7 to 14 2522.20 .314 .623210 bits 8 to 15 2539.22 .555 .710440 bits 9 to 16 2492.49 -.106 .457716 bits 10 to 17 2417.71 -1.164 .122258 bits 11 to 18 2639.77 1.977 .975962 bits 12 to 19 2529.52 .418 .661846 bits 13 to 20 2520.49 .290 .613990 bits 14 to 21 2388.58 -1.576 .057544 bits 15 to 22 2473.63 -.373 .354580 bits 16 to 23 2426.23 -1.043 .148409 bits 17 to 24 2581.95 1.159 .876759 bits 18 to 25 2578.96 1.117 .867918 bits 19 to 26 2554.61 .772 .780034 bits 20 to 27 2590.96 1.286 .900843 bits 21 to 28 2596.06 1.359 .912856 bits 22 to 29 2488.09 -.168 .433113 bits 23 to 30 2484.48 -.219 .413134 bits 24 to 31 2555.28 .782 .782834 bits 25 to 32 2545.30 .641 .739104 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bbs.32 Of 12,000 tries, the average no. of successes should be 3523 with sigma=21.9 Successes: 3481 z-score: -1.918 p-value: .027568 Successes: 3526 z-score: .137 p-value: .554479 Successes: 3545 z-score: 1.005 p-value: .842447 Successes: 3542 z-score: .868 p-value: .807188 Successes: 3489 z-score: -1.553 p-value: .060270 Successes: 3513 z-score: -.457 p-value: .323972 Successes: 3498 z-score: -1.142 p-value: .126820 Successes: 3523 z-score: .000 p-value: .500000 Successes: 3507 z-score: -.731 p-value: .232514 Successes: 3546 z-score: 1.050 p-value: .853193 square size avg. no. parked sample sigma 100. 3517.000 22.177 KSTEST for the above 10: p= .360847 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bbs.32 Sample no. d^2 avg equiv uni 5 .9378 .5297 .610370 10 .0629 .5144 .061273 15 .3572 .7165 .301612 20 .7039 .6736 .507099 25 .9253 .7817 .605439 30 3.2093 .9323 .960261 35 .1252 .9610 .118231 40 .5581 .9381 .429317 45 .7992 .9365 .552116 50 .4488 .8936 .363062 55 .1062 1.0378 .101271 60 1.0445 1.0319 .649974 65 .4247 .9740 .347416 70 .1390 .9863 .130365 75 .3401 .9629 .289520 80 .2111 .9212 .191144 85 .1768 .9454 .162821 90 .8316 .9932 .566460 95 .2094 .9922 .189748 100 .1097 .9738 .104389 MINIMUM DISTANCE TEST for bbs.32 Result of KS test on 20 transformed mindist^2's: p-value= .484088 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bbs.32 sample no: 1 r^3= 57.425 p-value= .85254 sample no: 2 r^3= 78.185 p-value= .92618 sample no: 3 r^3= 34.952 p-value= .68810 sample no: 4 r^3= 36.078 p-value= .69959 sample no: 5 r^3= 1.748 p-value= .05661 sample no: 6 r^3= 27.541 p-value= .60070 sample no: 7 r^3= 27.772 p-value= .60375 sample no: 8 r^3= 5.883 p-value= .17806 sample no: 9 r^3= 45.855 p-value= .78314 sample no: 10 r^3= 6.554 p-value= .19625 sample no: 11 r^3= 27.579 p-value= .60120 sample no: 12 r^3= 5.811 p-value= .17611 sample no: 13 r^3= 10.421 p-value= .29345 sample no: 14 r^3= 15.396 p-value= .40141 sample no: 15 r^3= 2.275 p-value= .07301 sample no: 16 r^3= 47.912 p-value= .79751 sample no: 17 r^3= 27.933 p-value= .60588 sample no: 18 r^3= 46.603 p-value= .78848 sample no: 19 r^3= 39.484 p-value= .73183 sample no: 20 r^3= 14.490 p-value= .38308 A KS test is applied to those 20 p-values. --------------------------------------------------------- 3DSPHERES test for file bbs.32 p-value= .251159 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bbs.32 Table of standardized frequency counts ( (obs-exp)/sqrt(exp) )^2 for j taking values <=6,7,8,...,47,>=48: -.1 .5 -.4 -.5 -.1 1.9 1.2 -1.2 .0 .7 -.6 -.1 -.3 -.8 -1.3 .2 -.7 .1 .4 -.5 2.4 .5 1.1 -.9 .1 -.4 -.5 1.5 -.7 .6 -1.4 .9 -1.9 .8 .1 -.7 -.5 .5 .1 -.1 -.6 .0 .8 Chi-square with 42 degrees of freedom: 32.204 z-score= -1.069 p-value= .137417 ______________________________________________________________ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 .856594 Test no. 2 p-value .181666 Test no. 3 p-value .294062 Test no. 4 p-value .883345 Test no. 5 p-value .686900 Test no. 6 p-value .955357 Test no. 7 p-value .301129 Test no. 8 p-value .666933 Test no. 9 p-value .681837 Test no. 10 p-value .976020 Results of the OSUM test for bbs.32 KSTEST on the above 10 p-values: .860299 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bbs.32 Up and down runs in a sample of 10000 _________________________________________________ Run test for bbs.32 : runs up; ks test for 10 p's: .168184 runs down; ks test for 10 p's: .480434 Run test for bbs.32 : runs up; ks test for 10 p's: .801154 runs down; ks test for 10 p's: .705166 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 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 bbs.32 No. of wins: Observed Expected 98663 98585.86 98663= No. of wins, z-score= .345 pvalue= .63496 Analysis of Throws-per-Game: Chisq= 21.71 for 20 degrees of freedom, p= .64328 Throws Observed Expected Chisq Sum 1 66613 66666.7 .043 .043 2 37548 37654.3 .300 .343 3 26994 26954.7 .057 .401 4 19149 19313.5 1.400 1.801 5 13995 13851.4 1.488 3.289 6 9964 9943.5 .042 3.332 7 7180 7145.0 .171 3.503 8 5214 5139.1 1.092 4.595 9 3744 3699.9 .526 5.122 10 2615 2666.3 .987 6.109 11 2025 1923.3 5.375 11.483 12 1368 1388.7 .310 11.793 13 932 1003.7 5.124 16.917 14 715 726.1 .171 17.088 15 554 525.8 1.509 18.596 16 382 381.2 .002 18.598 17 253 276.5 2.004 20.602 18 196 200.8 .116 20.718 19 146 146.0 .000 20.718 20 111 106.2 .216 20.934 21 302 287.1 .772 21.705 SUMMARY FOR bbs.32 p-value for no. of wins: .634960 p-value for throws/game: .643281 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Results of DIEHARD battery of tests sent to file bbs.out3
Private
[
?
]
Run code
Submit