Script started on Fri Aug 6 21:44:38 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 testurandom (no_bdays=1024, no_days/yr=2^24, lambda=16.00, sample size=500) Bits used mean chisqr p-value 1 to 24 15.83 10.5347 0.879706 2 to 25 16.03 12.0286 0.798404 3 to 26 15.85 13.5101 0.701424 4 to 27 15.83 16.4537 0.491932 5 to 28 15.66 18.6644 0.348130 6 to 29 15.75 17.6942 0.408373 7 to 30 16.05 5.4065 0.996368 8 to 31 15.83 9.2881 0.930787 9 to 32 15.31 24.9864 0.095015 degree of freedoms is: 17 --------------------------------------------------------------- p-value for KStest on those 9 p-values: 0.253870 |-------------------------------------------------------------| | 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=248913586642.863525 with df=99; p-value= nan _______________________________________________________________ sample 2 chisquare=-1450922550150.305908 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 testurandom RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=28 190 211.4 2.170 2.170 r=29 5204 5134.0 0.954 3.124 r=30 23148 23103.0 0.087 3.211 r=31 11458 11551.5 0.757 3.969 chi-square = 3.969 with df = 3; p-value = 0.265 -------------------------------------------------------------- |-------------------------------------------------------------| |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 testurandom RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=29 190 211.4 2.170 2.170 r=30 5222 5134.0 1.508 3.678 r=31 23094 23103.0 0.004 3.681 r=32 11494 11551.5 0.286 3.968 chi-square = 3.968 with df = 3; p-value = 0.265 -------------------------------------------------------------- |-------------------------------------------------------------| |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 testurandom bits 1 to 8 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 990 944.3 2.212 2.212 r=5 21637 21743.9 0.526 2.737 r=6 77373 77311.8 0.048 2.786 chi-square = 2.786 with df = 2; p-value = 0.248 -------------------------------------------------------------- bits 2 to 9 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 924 944.3 0.436 0.436 r=5 21751 21743.9 0.002 0.439 r=6 77325 77311.8 0.002 0.441 chi-square = 0.441 with df = 2; p-value = 0.802 -------------------------------------------------------------- bits 3 to 10 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 913 944.3 1.037 1.037 r=5 21697 21743.9 0.101 1.139 r=6 77390 77311.8 0.079 1.218 chi-square = 1.218 with df = 2; p-value = 0.544 -------------------------------------------------------------- bits 4 to 11 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 938 944.3 0.042 0.042 r=5 21613 21743.9 0.788 0.830 r=6 77449 77311.8 0.243 1.074 chi-square = 1.074 with df = 2; p-value = 0.585 -------------------------------------------------------------- bits 5 to 12 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 943 944.3 0.002 0.002 r=5 21603 21743.9 0.913 0.915 r=6 77454 77311.8 0.262 1.176 chi-square = 1.176 with df = 2; p-value = 0.555 -------------------------------------------------------------- bits 6 to 13 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 965 944.3 0.454 0.454 r=5 21506 21743.9 2.603 3.057 r=6 77529 77311.8 0.610 3.667 chi-square = 3.667 with df = 2; p-value = 0.160 -------------------------------------------------------------- bits 7 to 14 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 992 944.3 2.409 2.409 r=5 21546 21743.9 1.801 4.211 r=6 77462 77311.8 0.292 4.502 chi-square = 4.502 with df = 2; p-value = 0.105 -------------------------------------------------------------- bits 8 to 15 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 970 944.3 0.699 0.699 r=5 21870 21743.9 0.731 1.431 r=6 77160 77311.8 0.298 1.729 chi-square = 1.729 with df = 2; p-value = 0.421 -------------------------------------------------------------- bits 9 to 16 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 1004 944.3 3.774 3.774 r=5 21971 21743.9 2.372 6.146 r=6 77025 77311.8 1.064 7.210 chi-square = 7.210 with df = 2; p-value = 0.027 -------------------------------------------------------------- bits 10 to 17 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 986 944.3 1.841 1.841 r=5 22046 21743.9 4.197 6.039 r=6 76968 77311.8 1.529 7.568 chi-square = 7.568 with df = 2; p-value = 0.023 -------------------------------------------------------------- bits 11 to 18 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 963 944.3 0.370 0.370 r=5 21882 21743.9 0.877 1.247 r=6 77155 77311.8 0.318 1.565 chi-square = 1.565 with df = 2; p-value = 0.457 -------------------------------------------------------------- bits 12 to 19 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 934 944.3 0.112 0.112 r=5 21866 21743.9 0.686 0.798 r=6 77200 77311.8 0.162 0.960 chi-square = 0.960 with df = 2; p-value = 0.619 -------------------------------------------------------------- bits 13 to 20 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 936 944.3 0.073 0.073 r=5 22046 21743.9 4.197 4.270 r=6 77018 77311.8 1.116 5.387 chi-square = 5.387 with df = 2; p-value = 0.068 -------------------------------------------------------------- bits 14 to 21 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 939 944.3 0.030 0.030 r=5 21913 21743.9 1.315 1.345 r=6 77148 77311.8 0.347 1.692 chi-square = 1.692 with df = 2; p-value = 0.429 -------------------------------------------------------------- bits 15 to 22 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 963 944.3 0.370 0.370 r=5 21969 21743.9 2.330 2.701 r=6 77068 77311.8 0.769 3.469 chi-square = 3.469 with df = 2; p-value = 0.176 -------------------------------------------------------------- bits 16 to 23 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 985 944.3 1.754 1.754 r=5 21792 21743.9 0.106 1.861 r=6 77223 77311.8 0.102 1.963 chi-square = 1.963 with df = 2; p-value = 0.375 -------------------------------------------------------------- bits 17 to 24 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 956 944.3 0.145 0.145 r=5 21891 21743.9 0.995 1.140 r=6 77153 77311.8 0.326 1.466 chi-square = 1.466 with df = 2; p-value = 0.480 -------------------------------------------------------------- bits 18 to 25 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 956 944.3 0.145 0.145 r=5 22073 21743.9 4.981 5.126 r=6 76971 77311.8 1.502 6.628 chi-square = 6.628 with df = 2; p-value = 0.036 -------------------------------------------------------------- bits 19 to 26 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 989 944.3 2.116 2.116 r=5 21831 21743.9 0.349 2.465 r=6 77180 77311.8 0.225 2.690 chi-square = 2.690 with df = 2; p-value = 0.261 -------------------------------------------------------------- bits 20 to 27 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 949 944.3 0.023 0.023 r=5 21854 21743.9 0.557 0.581 r=6 77197 77311.8 0.170 0.751 chi-square = 0.751 with df = 2; p-value = 0.687 -------------------------------------------------------------- bits 21 to 28 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 980 944.3 1.350 1.350 r=5 21688 21743.9 0.144 1.493 r=6 77332 77311.8 0.005 1.499 chi-square = 1.499 with df = 2; p-value = 0.473 -------------------------------------------------------------- bits 22 to 29 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 1000 944.3 3.285 3.285 r=5 21832 21743.9 0.357 3.642 r=6 77168 77311.8 0.267 3.910 chi-square = 3.910 with df = 2; p-value = 0.142 -------------------------------------------------------------- bits 23 to 30 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 938 944.3 0.042 0.042 r=5 21925 21743.9 1.508 1.550 r=6 77137 77311.8 0.395 1.946 chi-square = 1.946 with df = 2; p-value = 0.378 -------------------------------------------------------------- bits 24 to 31 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 948 944.3 0.014 0.014 r=5 21778 21743.9 0.053 0.068 r=6 77274 77311.8 0.018 0.086 chi-square = 0.086 with df = 2; p-value = 0.958 -------------------------------------------------------------- bits 25 to 32 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 952 944.3 0.063 0.063 r=5 21875 21743.9 0.790 0.853 r=6 77173 77311.8 0.249 1.102 chi-square = 1.102 with df = 2; p-value = 0.576 -------------------------------------------------------------- TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices These should be 25 uniform [0,1] random variates: 0.248369 0.802130 0.543966 0.584634 0.555335 0.159867 0.105269 0.421304 0.027185 0.022737 0.457163 0.618889 0.067654 0.429158 0.176450 0.374824 0.480395 0.036365 0.260600 0.686826 0.472685 0.141570 0.378025 0.957693 0.576253 The KS test for those 25 supposed UNI's yields KS p-value = 0.058630 |-------------------------------------------------------------| | 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 testurandom (20 bits/word, 2097152 words 20 bitstreams. No. missing words should average 141909.33 with sigma=428.00.) ---------------------------------------------------------------- BITSTREAM test results for testurandom. Bitstream No. missing words z-score p-value 1 142263 0.83 0.204308 2 142197 0.67 0.250752 3 142593 1.60 0.055093 4 141856 -0.12 0.549581 5 141343 -1.32 0.907116 6 142263 0.83 0.204308 7 141597 -0.73 0.767226 8 141924 0.03 0.486329 9 141275 -1.48 0.930840 10 142772 2.02 0.021922 11 142541 1.48 0.069990 12 141941 0.07 0.470507 13 141152 -1.77 0.961592 14 142730 1.92 0.027590 15 141934 0.06 0.477018 16 141976 0.16 0.438107 17 142788 2.05 0.020038 18 141873 -0.08 0.533823 19 142050 0.33 0.371203 20 142626 1.67 0.047020 ---------------------------------------------------------------- |-------------------------------------------------------------| | 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 testurandom Bits used No. missing words z-score p-value 23 to 32 141918 0.0299 0.488075 22 to 31 142179 0.9299 0.176212 21 to 30 142470 1.9333 0.026597 20 to 29 141823 -0.2977 0.617030 19 to 28 141502 -1.4046 0.919928 18 to 27 141845 -0.2218 0.587776 17 to 26 141518 -1.3494 0.911398 16 to 25 142010 0.3471 0.364244 15 to 24 142075 0.5713 0.283906 14 to 23 141936 0.0920 0.463363 13 to 22 141991 0.2816 0.389117 12 to 21 142023 0.3920 0.347542 11 to 20 142180 0.9333 0.175321 10 to 19 141840 -0.2391 0.594474 9 to 18 142245 1.1575 0.123538 8 to 17 141930 0.0713 0.471589 7 to 16 141891 -0.0632 0.525199 6 to 15 141587 -1.1115 0.866820 5 to 14 142161 0.8678 0.192744 4 to 13 142251 1.1782 0.119364 3 to 12 141930 0.0713 0.471589 2 to 11 141827 -0.2839 0.611755 1 to 10 141649 -0.8977 0.815324 ----------------------------------------------------------------- |------------------------------------------------------------ | | 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 testurandom Bits used No. missing words z-score p-value 28 to 32 142232 1.0938 0.137022 27 to 31 142316 1.3785 0.084018 26 to 30 142165 0.8667 0.193059 25 to 29 142144 0.7955 0.213164 24 to 28 142218 1.0463 0.147702 23 to 27 142391 1.6328 0.051258 22 to 26 142408 1.6904 0.045475 21 to 25 141834 -0.2554 0.600776 20 to 24 141884 -0.0859 0.534213 19 to 23 142012 0.3480 0.363907 18 to 22 141775 -0.4554 0.675573 17 to 21 141743 -0.5638 0.713565 16 to 20 142070 0.5446 0.292999 15 to 19 141653 -0.8689 0.807553 14 to 18 142213 1.0294 0.151648 13 to 17 141486 -1.4350 0.924359 12 to 16 141687 -0.7537 0.774474 11 to 15 141762 -0.4994 0.691259 10 to 14 141667 -0.8215 0.794307 9 to 13 142315 1.3752 0.084542 8 to 12 142210 1.0192 0.154049 7 to 11 142298 1.3175 0.093831 6 to 10 141324 -1.9842 0.976382 5 to 9 141744 -0.5604 0.712411 4 to 8 141322 -1.9909 0.976757 3 to 7 141643 -0.9028 0.816688 2 to 6 142469 1.8972 0.028902 1 to 5 141511 -1.3503 0.911535 ----------------------------------------------------------------- |------------------------------------------------------------ | | 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 testurandom Bits used No. missing words z-score p-value 31 to 32 141724 -0.5467 0.707706 30 to 31 141504 -1.1957 0.884086 29 to 30 142057 0.4356 0.331562 28 to 29 141191 -2.1190 0.982953 27 to 28 142020 0.3265 0.372038 26 to 27 141947 0.1111 0.455760 25 to 26 141628 -0.8299 0.796697 24 to 25 141874 -0.1042 0.541502 23 to 24 142091 0.5359 0.296014 22 to 23 141765 -0.4258 0.664856 21 to 22 142224 0.9282 0.176644 20 to 21 142048 0.4091 0.341249 19 to 20 141908 -0.0039 0.501565 18 to 19 142545 1.8751 0.030387 17 to 18 142151 0.7129 0.237957 16 to 17 141903 -0.0187 0.507449 15 to 16 141829 -0.2370 0.593657 14 to 15 141951 0.1229 0.451085 13 to 14 141633 -0.8151 0.792502 12 to 13 142060 0.4445 0.328357 11 to 12 142063 0.4533 0.325165 10 to 11 141964 0.1613 0.435941 9 to 10 141994 0.2498 0.401385 8 to 9 141391 -1.5290 0.936867 7 to 8 141850 -0.1750 0.569466 6 to 7 141950 0.1200 0.452253 5 to 6 141765 -0.4258 0.664856 4 to 5 142065 0.4592 0.323044 3 to 4 141439 -1.3874 0.917341 2 to 3 141825 -0.2488 0.598227 1 to 2 142204 0.8692 0.192360 ----------------------------------------------------------------- |-------------------------------------------------------------| | 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 testurandom (Degrees of freedom: 5^4-5^3=2500; sample size: 2560000) chisquare z-score p-value 2450.81 -0.696 0.756686 |-------------------------------------------------------------| | 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 testurandom (Degrees of freedom: 5^4-5^3=2500; sample size: 256000) bits used chisquare z-score p-value 1 to 8 2388.22 -1.581 0.943043 2 to 9 2343.70 -2.210 0.986464 3 to 10 2513.29 0.188 0.425486 4 to 11 2484.89 -0.214 0.584610 5 to 12 2472.49 -0.389 0.651372 6 to 13 2549.71 0.703 0.241023 7 to 14 2421.51 -1.110 0.866492 8 to 15 2453.73 -0.654 0.743541 9 to 16 2567.24 0.951 0.170817 10 to 17 2617.06 1.655 0.048919 11 to 18 2426.55 -1.039 0.850546 12 to 19 2547.35 0.670 0.251545 13 to 20 2457.12 -0.606 0.727869 14 to 21 2544.84 0.634 0.263016 15 to 22 2517.28 0.244 0.403460 16 to 23 2589.45 1.265 0.102933 17 to 24 2505.48 0.078 0.469086 18 to 25 2496.35 -0.052 0.520601 19 to 26 2592.33 1.306 0.095811 20 to 27 2669.02 2.390 0.008417 21 to 28 2509.34 0.132 0.447444 22 to 29 2507.13 0.101 0.459835 23 to 30 2565.60 0.928 0.176782 24 to 31 2515.50 0.219 0.413257 25 to 32 2582.85 1.172 0.120666 |-------------------------------------------------------------| | 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 testurandom (Of 12000 tries, the average no. of successes should be 3523.0 with sigma=21.9) No. succeses z-score p-value 3521 -0.0913 0.536383 3543 0.9132 0.180558 3526 0.1370 0.445521 3571 2.1918 0.014198 3520 -0.1370 0.554479 3523 0.0000 0.500000 3534 0.5023 0.307734 3531 0.3653 0.357445 3523 0.0000 0.500000 3552 1.3242 0.092718 Square side=100, avg. no. parked=3534.40 sample std.=15.66 p-value of the KSTEST for those 10 p-values: 0.000313 |-------------------------------------------------------------| | 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 testurandom Sample no. d^2 mean equiv uni 5 0.2070 1.5426 0.187846 10 1.6606 1.3450 0.811550 15 1.3593 1.3527 0.744902 20 0.1683 1.2074 0.155654 25 0.2255 1.1222 0.202820 30 1.6023 1.1591 0.800187 35 0.1556 1.1125 0.144790 40 0.5654 1.0126 0.433452 45 0.8764 0.9690 0.585562 50 1.5572 1.0530 0.790908 55 0.8420 1.0266 0.570987 60 1.8473 1.0711 0.843798 65 3.7730 1.0969 0.977448 70 0.5359 1.0393 0.416429 75 1.2198 1.0019 0.706519 80 3.0053 1.0387 0.951218 85 1.5011 1.0495 0.778792 90 0.1964 1.0256 0.179101 95 0.8186 0.9962 0.560747 100 0.2449 1.0192 0.218161 -------------------------------------------------------------- Result of KS test on 100 transformed mindist^2's: p-value=0.983000 |-------------------------------------------------------------| | 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 testurandom sample no r^3 equiv. uni. 1 56.557 0.848208 2 1.663 0.053917 3 81.819 0.934604 4 151.650 0.993623 5 16.418 0.421474 6 0.364 0.012070 7 0.615 0.020293 8 23.406 0.541679 9 4.571 0.141322 10 16.612 0.425191 11 4.331 0.134416 12 10.524 0.295884 13 1.854 0.059936 14 10.417 0.293352 15 39.689 0.733657 16 20.265 0.491093 17 36.980 0.708488 18 1.401 0.045640 19 52.933 0.828716 20 1.382 0.045020 -------------------------------------------------------------- p-value for KS test on those 20 p-values: 0.056397 |-------------------------------------------------------------| | 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 testurandom Table of standardized frequency counts (obs-exp)^2/exp for j=(1,..,6), 7,...,47,(48,...) -0.1 -2.0 0.1 -1.3 -0.6 -1.3 0.8 1.0 0.5 0.3 -1.2 -0.1 0.5 0.7 0.9 -0.6 0.5 -1.2 -0.3 0.7 -0.6 -0.3 -0.4 0.4 -0.6 1.6 0.1 0.6 0.1 -1.0 -0.0 0.4 -0.3 -1.1 -1.2 1.1 -1.9 1.1 2.1 1.5 -0.6 0.0 -1.1 Chi-square with 42 degrees of freedom:37.824401 z-score=-0.455595, p-value=0.654757 _____________________________________________________________ |-------------------------------------------------------------| | 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 testurandom Test no p-value 1 0.847891 2 0.470750 3 0.900977 4 0.594465 5 0.422142 6 0.622332 7 0.306433 8 0.019589 9 0.194098 10 0.004986 _____________________________________________________________ p-value for 10 kstests on 100 kstests:0.509204 |-------------------------------------------------------------| | 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 testurandom (Up and down runs in a sequence of 10000 numbers) Set 1 runs up; ks test for 10 p's: 0.988601 runs down; ks test for 10 p's: 0.405862 Set 2 runs up; ks test for 10 p's: 0.901009 runs down; ks test for 10 p's: 0.733961 |-------------------------------------------------------------| |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 testurandom No. of wins: Observed Expected 98341 98585.858586 z-score=-1.095, pvalue=0.86327 Analysis of Throws-per-Game: Throws Observed Expected Chisq Sum of (O-E)^2/E 1 66306 66666.7 1.951 1.951 2 37955 37654.3 2.401 4.352 3 26757 26954.7 1.451 5.803 4 19534 19313.5 2.518 8.321 5 13876 13851.4 0.044 8.365 6 10064 9943.5 1.459 9.824 7 7117 7145.0 0.110 9.934 8 5044 5139.1 1.759 11.693 9 3736 3699.9 0.353 12.046 10 2764 2666.3 3.580 15.626 11 1907 1923.3 0.139 15.764 12 1367 1388.7 0.340 16.105 13 953 1003.7 2.562 18.667 14 706 726.1 0.559 19.226 15 511 525.8 0.419 19.644 16 393 381.2 0.368 20.013 17 244 276.5 3.829 23.842 18 196 200.8 0.116 23.958 19 139 146.0 0.334 24.292 20 127 106.2 4.067 28.359 21 304 287.1 0.993 29.352 Chisq= 29.35 for 20 degrees of freedom, p= 0.08105 SUMMARY of craptest on testurandom p-value for no. of wins: 0.863275 p-value for throws/game: 0.081051 _____________________________________________________________ x64# exit Script done on Fri Aug 6 21:45:07 2010