Script started on Fri Aug 6 21:44:00 2010 x64# 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=1-F(X), where F is the assumed distribution of the sample random variable X---often normal. But that assumed F is often just an asymptotic approximation, for which the fit will be worst in the tails. Thus you should not be surprised with occasion- al 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 RNGs. So keep in mind that "p happens" Enter the name of the file to be tested. This must be a form="unformatted",access="direct" binary file of about 10-12 million bytes. Enter file name: warning: this program uses gets(), which is unsafe. HERE ARE YOUR CHOICES: 1 Birthday Spacings 2 Overlapping Permutations 3 Ranks of 31x31 and 32x32 matrices 4 Ranks of 6x8 Matrices 5 Monkey Tests on 20-bit Words 6 Monkey Tests OPSO,OQSO,DNA 7 Count the 1`s in a Stream of Bytes 8 Count the 1`s in Specific Bytes 9 Parking Lot Test 10 Minimum Distance Test 11 Random Spheres Test 12 The Sqeeze Test 13 Overlapping Sums Test 14 Runs Test 15 The Craps Test 16 All of the above To choose any particular tests, enter corresponding numbers. Enter 16 for all tests. If you want to perform all but a few tests, enter corresponding numbers preceded by "-" sign. Tests are executed in the order they are entered. Enter your choices. |-------------------------------------------------------------| | This is the BIRTHDAY SPACINGS TEST | |Choose m birthdays in a "year" of n days. List the spacings | |between the birthdays. Let j be 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^10, so that the underlying distribution for j | |is taken to be Poisson with lambda=2^30/(2^26)=16. A sample | |of 200 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, then bits 2-25 of the same inte-| |gers are used to provide birthdays, 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. | |------------------------------------------------------------ | RESULTS OF BIRTHDAY SPACINGS TEST FOR testrandom (no_bdays=1024, no_days/yr=2^24, lambda=16.00, sample size=500) Bits used mean chisqr p-value 1 to 24 15.95 9.5330 0.922044 2 to 25 15.96 6.9571 0.984097 3 to 26 15.84 10.0841 0.900046 4 to 27 15.70 18.7220 0.344721 5 to 28 15.88 19.3682 0.307812 6 to 29 15.74 12.7176 0.754878 7 to 30 15.29 30.2626 0.024512 8 to 31 15.67 15.9206 0.529473 9 to 32 15.63 14.9645 0.598040 degree of freedoms is: 17 --------------------------------------------------------------- p-value for KStest on those 9 p-values: 0.443810 |-------------------------------------------------------------| | 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 (For samples of 1,000,000 consecutive 5-tuples) sample 1 chisquare=3774632125317.211914 with df=99; p-value= nan _______________________________________________________________ sample 2 chisquare=3809142437.101739 with df=99; p-value= nan _______________________________________________________________ |-------------------------------------------------------------| |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 chisqu-| |are test is performed on counts for ranks 31,30,28 and <=28. | |-------------------------------------------------------------| Rank test for binary matrices (31x31) from testrandom RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=28 195 211.4 1.275 1.275 r=29 5097 5134.0 0.267 1.542 r=30 23037 23103.0 0.189 1.731 r=31 11671 11551.5 1.236 2.966 chi-square = 2.966 with df = 3; p-value = 0.397 -------------------------------------------------------------- |-------------------------------------------------------------| |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. | |-------------------------------------------------------------| Rank test for binary matrices (32x32) from testrandom RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=29 204 211.4 0.260 0.260 r=30 5120 5134.0 0.038 0.299 r=31 22974 23103.0 0.721 1.019 r=32 11702 11551.5 1.960 2.980 chi-square = 2.980 with df = 3; p-value = 0.395 -------------------------------------------------------------- |-------------------------------------------------------------| |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 (0,...,4) (pooled together). | |-------------------------------------------------------------| Rank test for binary matrices (6x8) from testrandom bits 1 to 8 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 916 944.3 0.848 0.848 r=5 21656 21743.9 0.355 1.203 r=6 77428 77311.8 0.175 1.378 chi-square = 1.378 with df = 2; p-value = 0.502 -------------------------------------------------------------- bits 2 to 9 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 948 944.3 0.014 0.014 r=5 21665 21743.9 0.286 0.301 r=6 77387 77311.8 0.073 0.374 chi-square = 0.374 with df = 2; p-value = 0.829 -------------------------------------------------------------- bits 3 to 10 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 949 944.3 0.023 0.023 r=5 21962 21743.9 2.188 2.211 r=6 77089 77311.8 0.642 2.853 chi-square = 2.853 with df = 2; p-value = 0.240 -------------------------------------------------------------- bits 4 to 11 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 962 944.3 0.332 0.332 r=5 21789 21743.9 0.094 0.425 r=6 77249 77311.8 0.051 0.476 chi-square = 0.476 with df = 2; p-value = 0.788 -------------------------------------------------------------- bits 5 to 12 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 889 944.3 3.238 3.238 r=5 21946 21743.9 1.878 5.117 r=6 77165 77311.8 0.279 5.396 chi-square = 5.396 with df = 2; p-value = 0.067 -------------------------------------------------------------- bits 6 to 13 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 933 944.3 0.135 0.135 r=5 21718 21743.9 0.031 0.166 r=6 77349 77311.8 0.018 0.184 chi-square = 0.184 with df = 2; p-value = 0.912 -------------------------------------------------------------- bits 7 to 14 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 985 944.3 1.754 1.754 r=5 21697 21743.9 0.101 1.855 r=6 77318 77311.8 0.000 1.856 chi-square = 1.856 with df = 2; p-value = 0.395 -------------------------------------------------------------- bits 8 to 15 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 985 944.3 1.754 1.754 r=5 21693 21743.9 0.119 1.873 r=6 77322 77311.8 0.001 1.875 chi-square = 1.875 with df = 2; p-value = 0.392 -------------------------------------------------------------- bits 9 to 16 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 957 944.3 0.171 0.171 r=5 21803 21743.9 0.161 0.331 r=6 77240 77311.8 0.067 0.398 chi-square = 0.398 with df = 2; p-value = 0.820 -------------------------------------------------------------- bits 10 to 17 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 974 944.3 0.934 0.934 r=5 21964 21743.9 2.228 3.162 r=6 77062 77311.8 0.807 3.969 chi-square = 3.969 with df = 2; p-value = 0.137 -------------------------------------------------------------- bits 11 to 18 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 936 944.3 0.073 0.073 r=5 21941 21743.9 1.787 1.860 r=6 77123 77311.8 0.461 2.321 chi-square = 2.321 with df = 2; p-value = 0.313 -------------------------------------------------------------- bits 12 to 19 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 1013 944.3 4.998 4.998 r=5 21813 21743.9 0.220 5.218 r=6 77174 77311.8 0.246 5.463 chi-square = 5.463 with df = 2; p-value = 0.065 -------------------------------------------------------------- bits 13 to 20 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 995 944.3 2.722 2.722 r=5 21955 21743.9 2.049 4.772 r=6 77050 77311.8 0.887 5.658 chi-square = 5.658 with df = 2; p-value = 0.059 -------------------------------------------------------------- bits 14 to 21 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 1002 944.3 3.526 3.526 r=5 21925 21743.9 1.508 5.034 r=6 77073 77311.8 0.738 5.772 chi-square = 5.772 with df = 2; p-value = 0.056 -------------------------------------------------------------- bits 15 to 22 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 969 944.3 0.646 0.646 r=5 21859 21743.9 0.609 1.255 r=6 77172 77311.8 0.253 1.508 chi-square = 1.508 with df = 2; p-value = 0.470 -------------------------------------------------------------- bits 16 to 23 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 954 944.3 0.100 0.100 r=5 21937 21743.9 1.715 1.814 r=6 77109 77311.8 0.532 2.346 chi-square = 2.346 with df = 2; p-value = 0.309 -------------------------------------------------------------- bits 17 to 24 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 951 944.3 0.048 0.048 r=5 21797 21743.9 0.130 0.177 r=6 77252 77311.8 0.046 0.223 chi-square = 0.223 with df = 2; p-value = 0.894 -------------------------------------------------------------- bits 18 to 25 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 874 944.3 5.234 5.234 r=5 21755 21743.9 0.006 5.239 r=6 77371 77311.8 0.045 5.285 chi-square = 5.285 with df = 2; p-value = 0.071 -------------------------------------------------------------- bits 19 to 26 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 931 944.3 0.187 0.187 r=5 21833 21743.9 0.365 0.552 r=6 77236 77311.8 0.074 0.627 chi-square = 0.627 with df = 2; p-value = 0.731 -------------------------------------------------------------- bits 20 to 27 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 910 944.3 1.246 1.246 r=5 21927 21743.9 1.542 2.788 r=6 77163 77311.8 0.286 3.074 chi-square = 3.074 with df = 2; p-value = 0.215 -------------------------------------------------------------- bits 21 to 28 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 918 944.3 0.732 0.732 r=5 21897 21743.9 1.078 1.810 r=6 77185 77311.8 0.208 2.018 chi-square = 2.018 with df = 2; p-value = 0.365 -------------------------------------------------------------- bits 22 to 29 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 951 944.3 0.048 0.048 r=5 21880 21743.9 0.852 0.899 r=6 77169 77311.8 0.264 1.163 chi-square = 1.163 with df = 2; p-value = 0.559 -------------------------------------------------------------- bits 23 to 30 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 946 944.3 0.003 0.003 r=5 22008 21743.9 3.208 3.211 r=6 77046 77311.8 0.914 4.125 chi-square = 4.125 with df = 2; p-value = 0.127 -------------------------------------------------------------- bits 24 to 31 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 977 944.3 1.132 1.132 r=5 21794 21743.9 0.115 1.248 r=6 77229 77311.8 0.089 1.336 chi-square = 1.336 with df = 2; p-value = 0.513 -------------------------------------------------------------- bits 25 to 32 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 986 944.3 1.841 1.841 r=5 21762 21743.9 0.015 1.857 r=6 77252 77311.8 0.046 1.903 chi-square = 1.903 with df = 2; p-value = 0.386 -------------------------------------------------------------- TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices These should be 25 uniform [0,1] random variates: 0.502049 0.829469 0.240136 0.788074 0.067352 0.912118 0.395372 0.391665 0.819501 0.137437 0.313384 0.065112 0.059069 0.055810 0.470446 0.309365 0.894283 0.071197 0.730977 0.215013 0.364503 0.559009 0.127159 0.512611 0.386204 The KS test for those 25 supposed UNI's yields KS p-value = 0.156435 |-------------------------------------------------------------| | 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 for testrandom (20 bits/word, 2097152 words 20 bitstreams. No. missing words should average 141909.33 with sigma=428.00.) ---------------------------------------------------------------- BITSTREAM test results for testrandom. Bitstream No. missing words z-score p-value 1 142206 0.69 0.244106 2 142188 0.65 0.257492 3 142026 0.27 0.392583 4 141876 -0.08 0.531036 5 140758 -2.69 0.996428 6 142256 0.81 0.208977 7 143260 3.16 0.000800 8 141932 0.05 0.478879 9 142023 0.27 0.395280 10 141810 -0.23 0.591762 11 141784 -0.29 0.615173 12 142408 1.17 0.121986 13 141904 -0.01 0.504968 14 142707 1.86 0.031181 15 141950 0.10 0.462148 16 142183 0.64 0.261276 17 141940 0.07 0.471437 18 141904 -0.01 0.504968 19 141146 -1.78 0.962746 20 142150 0.56 0.286951 ---------------------------------------------------------------- |-------------------------------------------------------------| | 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. | |------------------------------------------------------------ | OPSO test for file testrandom Bits used No. missing words z-score p-value 23 to 32 142196 0.9885 0.161450 22 to 31 141738 -0.5908 0.722670 21 to 30 142480 1.9678 0.024544 20 to 29 141883 -0.0908 0.536171 19 to 28 141966 0.1954 0.422534 18 to 27 141624 -0.9839 0.837417 17 to 26 141842 -0.2322 0.591798 16 to 25 141510 -1.3770 0.915744 15 to 24 142045 0.4678 0.319954 14 to 23 141777 -0.4563 0.675917 13 to 22 141362 -1.8873 0.970443 12 to 21 142206 1.0230 0.153154 11 to 20 141690 -0.7563 0.775268 10 to 19 141538 -1.2804 0.899806 9 to 18 141588 -1.1080 0.866077 8 to 17 142209 1.0333 0.150721 7 to 16 142843 3.2196 0.000642 6 to 15 142061 0.5230 0.300487 5 to 14 141894 -0.0529 0.521079 4 to 13 141807 -0.3529 0.637904 3 to 12 142143 0.8058 0.210191 2 to 11 141413 -1.7115 0.956504 1 to 10 141585 -1.1184 0.868297 ----------------------------------------------------------------- |------------------------------------------------------------ | | 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. | |------------------------------------------------------------ | OQSO test for file testrandom Bits used No. missing words z-score p-value 28 to 32 141863 -0.1571 0.562398 27 to 31 142239 1.1175 0.131885 26 to 30 141679 -0.7808 0.782534 25 to 29 141835 -0.2520 0.599466 24 to 28 142390 1.6294 0.051615 23 to 27 141506 -1.3672 0.914222 22 to 26 141838 -0.2418 0.595531 21 to 25 141901 -0.0282 0.511263 20 to 24 142027 0.3989 0.344990 19 to 23 142538 2.1311 0.016541 18 to 22 142009 0.3379 0.367733 17 to 21 142174 0.8972 0.184810 16 to 20 141770 -0.4723 0.681645 15 to 19 141612 -1.0079 0.843248 14 to 18 141798 -0.3774 0.647058 13 to 17 141673 -0.8011 0.788468 12 to 16 141330 -1.9638 0.975225 11 to 15 141992 0.2802 0.389648 10 to 14 141773 -0.4621 0.678008 9 to 13 142030 0.4091 0.341251 8 to 12 142149 0.8124 0.208269 7 to 11 142122 0.7209 0.235481 6 to 10 141583 -1.1062 0.865681 5 to 9 141821 -0.2994 0.617692 4 to 8 141690 -0.7435 0.771408 3 to 7 141793 -0.3943 0.653335 2 to 6 142331 1.4294 0.076446 1 to 5 142112 0.6870 0.246036 ----------------------------------------------------------------- |------------------------------------------------------------ | | 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. | |------------------------------------------------------------ | DNA test for file testrandom Bits used No. missing words z-score p-value 31 to 32 142792 2.6037 0.004611 30 to 31 141977 0.1996 0.420890 29 to 30 141931 0.0639 0.474516 28 to 29 141763 -0.4317 0.667003 27 to 28 141276 -1.8682 0.969135 26 to 27 141847 -0.1839 0.572940 25 to 26 142183 0.8073 0.209751 24 to 25 141726 -0.5408 0.705676 23 to 24 141569 -1.0039 0.842292 22 to 23 142116 0.6096 0.271048 21 to 22 141827 -0.2429 0.595944 20 to 21 141737 -0.5083 0.694395 19 to 20 142073 0.4828 0.314618 18 to 19 141895 -0.0423 0.516859 17 to 18 141538 -1.0954 0.863322 16 to 17 141697 -0.6263 0.734455 15 to 16 142247 0.9961 0.159606 14 to 15 141820 -0.2635 0.603921 13 to 14 142103 0.5713 0.283899 12 to 13 141979 0.2055 0.418584 11 to 12 141742 -0.4936 0.689205 10 to 11 142238 0.9695 0.166141 9 to 10 141564 -1.0187 0.845821 8 to 9 142234 0.9577 0.169100 7 to 8 142006 0.2852 0.387760 6 to 7 142263 1.0433 0.148411 5 to 6 141621 -0.8505 0.802485 4 to 5 141889 -0.0600 0.523910 3 to 4 141666 -0.7178 0.763556 2 to 3 142372 1.3648 0.086157 1 to 2 142473 1.6627 0.048182 ----------------------------------------------------------------- |-------------------------------------------------------------| | 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 result for the byte stream from testrandom (Degrees of freedom: 5^4-5^3=2500; sample size: 2560000) chisquare z-score p-value 2396.84 -1.459 0.927697 |-------------------------------------------------------------| | 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. | |-------------------------------------------------------------| Test results for specific bytes from testrandom (Degrees of freedom: 5^4-5^3=2500; sample size: 256000) bits used chisquare z-score p-value 1 to 8 2471.90 -0.397 0.654440 2 to 9 2492.56 -0.105 0.541915 3 to 10 2452.60 -0.670 0.748670 4 to 11 2398.34 -1.438 0.924732 5 to 12 2455.45 -0.630 0.735659 6 to 13 2476.95 -0.326 0.627784 7 to 14 2478.64 -0.302 0.618711 8 to 15 2505.59 0.079 0.468515 9 to 16 2590.76 1.284 0.099640 10 to 17 2499.23 -0.011 0.504357 11 to 18 2543.36 0.613 0.269872 12 to 19 2456.69 -0.613 0.729916 13 to 20 2405.23 -1.340 0.909908 14 to 21 2436.67 -0.896 0.814770 15 to 22 2556.31 0.796 0.212905 16 to 23 2530.62 0.433 0.332493 17 to 24 2475.99 -0.340 0.632916 18 to 25 2426.36 -1.041 0.851175 19 to 26 2458.33 -0.589 0.722191 20 to 27 2570.47 0.997 0.159482 21 to 28 2441.46 -0.828 0.796129 22 to 29 2407.98 -1.301 0.903423 23 to 30 2466.26 -0.477 0.683356 24 to 31 2504.44 0.063 0.474959 25 to 32 2421.68 -1.108 0.865985 |-------------------------------------------------------------| | 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 10 tests on file testrandom (Of 12000 tries, the average no. of successes should be 3523.0 with sigma=21.9) No. succeses z-score p-value 3499 -1.0959 0.863437 3529 0.2740 0.392053 3495 -1.2785 0.899470 3539 0.7306 0.232514 3526 0.1370 0.445521 3504 -0.8676 0.807188 3534 0.5023 0.307734 3525 0.0913 0.463617 3534 0.5023 0.307734 3497 -1.1872 0.882429 Square side=100, avg. no. parked=3518.20 sample std.=16.47 p-value of the KSTEST for those 10 p-values: 0.005685 |-------------------------------------------------------------| | 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 file testrandom Sample no. d^2 mean equiv uni 5 0.9227 1.7287 0.604387 10 0.2970 1.3089 0.258100 15 1.2419 1.1051 0.712959 20 3.2494 1.2225 0.961829 25 1.4644 1.2220 0.770480 30 1.4550 1.2838 0.768304 35 0.5639 1.2317 0.432608 40 0.3473 1.2149 0.294664 45 0.4873 1.1840 0.387216 50 0.1671 1.1248 0.154612 55 0.5763 1.0937 0.439640 60 3.0257 1.1028 0.952208 65 0.3114 1.1129 0.268734 70 2.0184 1.1008 0.868476 75 2.3543 1.1158 0.906156 80 0.1186 1.0733 0.112323 85 0.4278 1.0722 0.349471 90 0.6640 1.0716 0.486909 95 0.1626 1.0692 0.150743 100 0.3509 1.0503 0.297157 -------------------------------------------------------------- Result of KS test on 100 transformed mindist^2's: p-value=0.518067 |-------------------------------------------------------------| | 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 testrandom sample no r^3 equiv. uni. 1 32.995 0.667074 2 119.919 0.981635 3 91.868 0.953218 4 4.673 0.144252 5 12.211 0.334372 6 21.316 0.508621 7 33.013 0.667274 8 22.785 0.532098 9 11.076 0.308713 10 24.027 0.551075 11 31.840 0.654007 12 4.511 0.139607 13 1.599 0.051893 14 14.057 0.374100 15 63.883 0.881096 16 46.940 0.790843 17 12.466 0.340017 18 17.757 0.446724 19 28.563 0.614069 20 20.605 0.496841 -------------------------------------------------------------- p-value for KS test on those 20 p-values: 0.813801 |-------------------------------------------------------------| | This is the SQUEEZE 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 testrandom Table of standardized frequency counts (obs-exp)^2/exp for j=(1,..,6), 7,...,47,(48,...) -0.8 -1.2 0.1 -0.1 -1.1 -1.4 0.3 0.2 0.3 -0.3 -1.0 -1.2 0.9 0.4 0.4 0.1 0.5 0.9 -0.1 -0.7 -0.1 -0.5 -0.7 -2.2 1.5 0.5 1.4 0.8 0.5 -0.1 0.1 -1.0 0.1 1.4 0.2 0.6 0.3 0.2 1.3 -1.8 -0.6 -1.0 -1.1 Chi-square with 42 degrees of freedom:32.658870 z-score=-1.019201, p-value=0.848994 _____________________________________________________________ |-------------------------------------------------------------| | 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. | |-------------------------------------------------------------| Results of the OSUM test for testrandom Test no p-value 1 0.581267 2 0.408077 3 0.794463 4 0.047756 5 0.704096 6 0.769532 7 0.083872 8 0.349287 9 0.958265 10 0.387439 _____________________________________________________________ p-value for 10 kstests on 100 kstests:0.982251 |-------------------------------------------------------------| | 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| |another three sets of ten. | |-------------------------------------------------------------| The RUNS test for file testrandom (Up and down runs in a sequence of 10000 numbers) Set 1 runs up; ks test for 10 p's: 0.585442 runs down; ks test for 10 p's: 0.638405 Set 2 runs up; ks test for 10 p's: 0.340252 runs down; ks test for 10 p's: 0.831265 |-------------------------------------------------------------| |This the CRAPS TEST. It plays 200,000 games of craps, counts| |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), and | |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 testrandom No. of wins: Observed Expected 98565 98585.858586 z-score=-0.093, pvalue=0.53716 Analysis of Throws-per-Game: Throws Observed Expected Chisq Sum of (O-E)^2/E 1 66377 66666.7 1.259 1.259 2 37717 37654.3 0.104 1.363 3 27113 26954.7 0.929 2.292 4 19459 19313.5 1.097 3.389 5 14016 13851.4 1.956 5.344 6 9880 9943.5 0.406 5.751 7 7087 7145.0 0.471 6.222 8 5157 5139.1 0.063 6.284 9 3719 3699.9 0.099 6.383 10 2695 2666.3 0.309 6.692 11 1934 1923.3 0.059 6.751 12 1365 1388.7 0.406 7.157 13 950 1003.7 2.875 10.032 14 644 726.1 9.292 19.324 15 537 525.8 0.237 19.561 16 358 381.2 1.406 20.967 17 277 276.5 0.001 20.968 18 191 200.8 0.481 21.449 19 136 146.0 0.683 22.132 20 121 106.2 2.058 24.190 21 267 287.1 1.409 25.599 Chisq= 25.60 for 20 degrees of freedom, p= 0.17948 SUMMARY of craptest on testrandom p-value for no. of wins: 0.537164 p-value for throws/game: 0.179481 _____________________________________________________________ x64# exit Script done on Fri Aug 6 21:44:32 2010