Script started on Thu 30 Mar 2023 03:44:57 PM CDT $ diehard 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: randnumb_mt64.bin 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. 16 |-------------------------------------------------------------| | 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 randnumb_mt64.bin (no_bdays=1024, no_days/yr=2^24, lambda=16.00, sample size=500) Bits used mean chisqr p-value 1 to 24 15.78 15.8533 0.534258 2 to 25 15.78 12.3604 0.777841 3 to 26 15.81 14.4240 0.636896 4 to 27 15.52 25.3055 0.088078 5 to 28 15.60 32.0732 0.014736 6 to 29 15.57 20.2028 0.263990 7 to 30 16.16 11.2234 0.844720 8 to 31 15.62 14.4148 0.637550 9 to 32 15.66 31.6958 0.016412 degree of freedoms is: 17 --------------------------------------------------------------- p-value for KStest on those 9 p-values: 0.276060 |-------------------------------------------------------------| | 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 | |occurrences 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 randnumb_mt64.bin (For samples of 1,000,000 consecutive 5-tuples) sample 1 chisquare=74.677392 with df=99; p-value= 0.967568 _______________________________________________________________ sample 2 chisquare=98.153648 with df=99; p-value= 0.505140 _______________________________________________________________ |-------------------------------------------------------------| |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 randnumb_mt64.bin RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=28 200 211.4 0.617 0.617 r=29 5108 5134.0 0.132 0.748 r=30 22969 23103.0 0.778 1.526 r=31 11723 11551.5 2.545 4.072 chi-square = 4.072 with df = 3; p-value = 0.254 -------------------------------------------------------------- |-------------------------------------------------------------| |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 randnumb_mt64.bin RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=29 218 211.4 0.205 0.205 r=30 5214 5134.0 1.246 1.451 r=31 23063 23103.0 0.069 1.521 r=32 11505 11551.5 0.187 1.708 chi-square = 1.708 with df = 3; p-value = 0.635 -------------------------------------------------------------- |-------------------------------------------------------------| |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 randnumb_mt64.bin bits 1 to 8 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 977 944.3 1.132 1.132 r=5 21529 21743.9 2.124 3.256 r=6 77494 77311.8 0.429 3.686 chi-square = 3.686 with df = 2; p-value = 0.158 -------------------------------------------------------------- bits 2 to 9 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 911 944.3 1.174 1.174 r=5 21672 21743.9 0.238 1.412 r=6 77417 77311.8 0.143 1.555 chi-square = 1.555 with df = 2; p-value = 0.460 -------------------------------------------------------------- bits 3 to 10 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 926 944.3 0.355 0.355 r=5 21746 21743.9 0.000 0.355 r=6 77328 77311.8 0.003 0.358 chi-square = 0.358 with df = 2; p-value = 0.836 -------------------------------------------------------------- bits 4 to 11 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 920 944.3 0.625 0.625 r=5 21823 21743.9 0.288 0.913 r=6 77257 77311.8 0.039 0.952 chi-square = 0.952 with df = 2; p-value = 0.621 -------------------------------------------------------------- bits 5 to 12 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 941 944.3 0.012 0.012 r=5 21848 21743.9 0.498 0.510 r=6 77211 77311.8 0.131 0.641 chi-square = 0.641 with df = 2; p-value = 0.726 -------------------------------------------------------------- bits 6 to 13 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 947 944.3 0.008 0.008 r=5 21656 21743.9 0.355 0.363 r=6 77397 77311.8 0.094 0.457 chi-square = 0.457 with df = 2; p-value = 0.796 -------------------------------------------------------------- bits 7 to 14 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 935 944.3 0.092 0.092 r=5 21769 21743.9 0.029 0.121 r=6 77296 77311.8 0.003 0.124 chi-square = 0.124 with df = 2; p-value = 0.940 -------------------------------------------------------------- bits 8 to 15 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 933 944.3 0.135 0.135 r=5 21735 21743.9 0.004 0.139 r=6 77332 77311.8 0.005 0.144 chi-square = 0.144 with df = 2; p-value = 0.930 -------------------------------------------------------------- bits 9 to 16 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 995 944.3 2.722 2.722 r=5 21887 21743.9 0.942 3.664 r=6 77118 77311.8 0.486 4.150 chi-square = 4.150 with df = 2; p-value = 0.126 -------------------------------------------------------------- bits 10 to 17 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 1004 944.3 3.774 3.774 r=5 21906 21743.9 1.208 4.983 r=6 77090 77311.8 0.636 5.619 chi-square = 5.619 with df = 2; p-value = 0.060 -------------------------------------------------------------- bits 11 to 18 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 1024 944.3 6.727 6.727 r=5 21690 21743.9 0.134 6.860 r=6 77286 77311.8 0.009 6.869 chi-square = 6.869 with df = 2; p-value = 0.032 -------------------------------------------------------------- bits 12 to 19 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 961 944.3 0.295 0.295 r=5 21762 21743.9 0.015 0.310 r=6 77277 77311.8 0.016 0.326 chi-square = 0.326 with df = 2; p-value = 0.850 -------------------------------------------------------------- bits 13 to 20 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 942 944.3 0.006 0.006 r=5 21812 21743.9 0.213 0.219 r=6 77246 77311.8 0.056 0.275 chi-square = 0.275 with df = 2; p-value = 0.872 -------------------------------------------------------------- bits 14 to 21 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 1018 944.3 5.752 5.752 r=5 21769 21743.9 0.029 5.781 r=6 77213 77311.8 0.126 5.907 chi-square = 5.907 with df = 2; p-value = 0.052 -------------------------------------------------------------- bits 15 to 22 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 976 944.3 1.064 1.064 r=5 21664 21743.9 0.294 1.358 r=6 77360 77311.8 0.030 1.388 chi-square = 1.388 with df = 2; p-value = 0.500 -------------------------------------------------------------- bits 16 to 23 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 972 944.3 0.813 0.813 r=5 21507 21743.9 2.581 3.394 r=6 77521 77311.8 0.566 3.960 chi-square = 3.960 with df = 2; p-value = 0.138 -------------------------------------------------------------- bits 17 to 24 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 927 944.3 0.317 0.317 r=5 21808 21743.9 0.189 0.506 r=6 77265 77311.8 0.028 0.534 chi-square = 0.534 with df = 2; p-value = 0.766 -------------------------------------------------------------- bits 18 to 25 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 922 944.3 0.527 0.527 r=5 21913 21743.9 1.315 1.842 r=6 77165 77311.8 0.279 2.120 chi-square = 2.120 with df = 2; p-value = 0.346 -------------------------------------------------------------- bits 19 to 26 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 986 944.3 1.841 1.841 r=5 21870 21743.9 0.731 2.573 r=6 77144 77311.8 0.364 2.937 chi-square = 2.937 with df = 2; p-value = 0.230 -------------------------------------------------------------- bits 20 to 27 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 963 944.3 0.370 0.370 r=5 21808 21743.9 0.189 0.559 r=6 77229 77311.8 0.089 0.648 chi-square = 0.648 with df = 2; p-value = 0.723 -------------------------------------------------------------- bits 21 to 28 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 954 944.3 0.100 0.100 r=5 21674 21743.9 0.225 0.324 r=6 77372 77311.8 0.047 0.371 chi-square = 0.371 with df = 2; p-value = 0.831 -------------------------------------------------------------- bits 22 to 29 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 957 944.3 0.171 0.171 r=5 21876 21743.9 0.803 0.973 r=6 77167 77311.8 0.271 1.245 chi-square = 1.245 with df = 2; p-value = 0.537 -------------------------------------------------------------- bits 23 to 30 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 936 944.3 0.073 0.073 r=5 21866 21743.9 0.686 0.759 r=6 77198 77311.8 0.168 0.926 chi-square = 0.926 with df = 2; p-value = 0.629 -------------------------------------------------------------- bits 24 to 31 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 969 944.3 0.646 0.646 r=5 21835 21743.9 0.382 1.028 r=6 77196 77311.8 0.173 1.201 chi-square = 1.201 with df = 2; p-value = 0.548 -------------------------------------------------------------- bits 25 to 32 RANK OBSERVED EXPECTED (O-E)^2/E SUM r<=4 918 944.3 0.732 0.732 r=5 21799 21743.9 0.140 0.872 r=6 77283 77311.8 0.011 0.883 chi-square = 0.883 with df = 2; p-value = 0.643 -------------------------------------------------------------- TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices These should be 25 uniform [0,1] random variates: 0.158369 0.459508 0.836005 0.621290 0.725663 0.795746 0.939979 0.930465 0.125577 0.060232 0.032242 0.849561 0.871583 0.052149 0.499620 0.138093 0.765582 0.346380 0.230276 0.723265 0.830596 0.536723 0.629361 0.548481 0.643121 The KS test for those 25 supposed UNI's yields KS p-value = 0.634144 |-------------------------------------------------------------| | 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 randnumb_mt64.bin (20 bits/word, 2097152 words 20 bitstreams. No. missing words should average 141909.33 with sigma=428.00.) ---------------------------------------------------------------- BITSTREAM test results for randnumb_mt64.bin. Bitstream No. missing words z-score p-value 1 141963 0.13 0.450105 2 141821 -0.21 0.581752 3 141406 -1.18 0.880203 4 141082 -1.93 0.973383 5 141497 -0.96 0.832324 6 141748 -0.38 0.646891 7 141924 0.03 0.486329 8 142290 0.89 0.186890 9 142483 1.34 0.090066 10 141974 0.15 0.439949 11 142503 1.39 0.082709 12 141926 0.04 0.484466 13 142061 0.35 0.361531 14 141646 -0.62 0.730807 15 142075 0.39 0.349349 16 141952 0.10 0.460293 17 142113 0.48 0.317085 18 141385 -1.23 0.889726 19 141621 -0.67 0.749739 20 142034 0.29 0.385417 ---------------------------------------------------------------- |-------------------------------------------------------------| | 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 randnumb_mt64.bin Bits used No. missing words z-score p-value 23 to 32 141612 -1.0253 0.847383 22 to 31 141858 -0.1770 0.570246 21 to 30 141973 0.2196 0.413110 20 to 29 141977 0.2333 0.407747 19 to 28 141983 0.2540 0.399734 18 to 27 141941 0.1092 0.456519 17 to 26 141577 -1.1460 0.874095 16 to 25 142423 1.7713 0.038257 15 to 24 141904 -0.0184 0.507332 14 to 23 141766 -0.4942 0.689432 13 to 22 142008 0.3402 0.366837 12 to 21 141716 -0.6667 0.747504 11 to 20 141669 -0.8287 0.796370 10 to 19 141329 -2.0011 0.977311 9 to 18 141782 -0.4391 0.669694 8 to 17 142175 0.9161 0.179806 7 to 16 141793 -0.4011 0.655841 6 to 15 141824 -0.2942 0.615713 5 to 14 142115 0.7092 0.239098 4 to 13 142039 0.4471 0.327388 3 to 12 142003 0.3230 0.373348 2 to 11 141952 0.1471 0.441512 1 to 10 141608 -1.0391 0.850614 ----------------------------------------------------------------- |------------------------------------------------------------ | | 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 randnumb_mt64.bin Bits used No. missing words z-score p-value 28 to 32 142152 0.8226 0.205365 27 to 31 142144 0.7955 0.213164 26 to 30 141522 -1.3130 0.905406 25 to 29 141576 -1.1299 0.870748 24 to 28 142337 1.4497 0.073567 23 to 27 141628 -0.9537 0.829872 22 to 26 141695 -0.7265 0.766247 21 to 25 142020 0.3752 0.353773 20 to 24 141896 -0.0452 0.518021 19 to 23 142309 1.3548 0.087738 18 to 22 143011 3.7345 0.000094 17 to 21 141631 -0.9435 0.827285 16 to 20 141963 0.1819 0.427818 15 to 19 141544 -1.2384 0.892217 14 to 18 141857 -0.1774 0.570399 13 to 17 141260 -2.2011 0.986136 12 to 16 142086 0.5989 0.274626 11 to 15 142071 0.5480 0.291834 10 to 14 142145 0.7989 0.212180 9 to 13 142045 0.4599 0.322795 8 to 12 141762 -0.4994 0.691259 7 to 11 141775 -0.4554 0.675573 6 to 10 141613 -1.0045 0.842433 5 to 9 142305 1.3413 0.089919 4 to 8 141910 0.0023 0.499094 3 to 7 141509 -1.3571 0.912617 2 to 6 141837 -0.2452 0.596844 1 to 5 142017 0.3650 0.357562 ----------------------------------------------------------------- |------------------------------------------------------------ | | 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 randnumb_mt64.bin Bits used No. missing words z-score p-value 31 to 32 141536 -1.1013 0.864610 30 to 31 142554 1.9017 0.028606 29 to 30 141551 -1.0570 0.854749 28 to 29 141703 -0.6086 0.728619 27 to 28 141556 -1.0423 0.851357 26 to 27 141563 -1.0216 0.846520 25 to 26 141690 -0.6470 0.741181 24 to 25 141951 0.1229 0.451085 23 to 24 141601 -0.9095 0.818464 22 to 23 141602 -0.9066 0.817685 21 to 22 142376 1.3766 0.084317 20 to 21 142342 1.2763 0.100922 19 to 20 141483 -1.2576 0.895734 18 to 19 141623 -0.8446 0.800842 17 to 18 141699 -0.6204 0.732517 16 to 17 142328 1.2350 0.108412 15 to 16 141569 -1.0039 0.842292 14 to 15 141564 -1.0187 0.845821 13 to 14 142300 1.1524 0.124574 12 to 13 142033 0.3648 0.357627 11 to 12 142138 0.6745 0.249983 10 to 11 141845 -0.1898 0.575253 9 to 10 142475 1.6686 0.047594 8 to 9 141170 -2.1809 0.985405 7 to 8 141932 0.0669 0.473341 6 to 7 141987 0.2291 0.409390 5 to 6 141859 -0.1485 0.559012 4 to 5 141885 -0.0718 0.528607 3 to 4 142096 0.5506 0.290937 2 to 3 142067 0.4651 0.320929 1 to 2 141861 -0.1426 0.556684 ----------------------------------------------------------------- |-------------------------------------------------------------| | 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 randnumb_mt64.bin (Degrees of freedom: 5^4-5^3=2500; sample size: 2560000) chisquare z-score p-value 2469.78 -0.427 0.665422 |-------------------------------------------------------------| | 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 randnumb_mt64.bin (Degrees of freedom: 5^4-5^3=2500; sample size: 256000) bits used chisquare z-score p-value 1 to 8 2457.74 -0.598 0.724951 2 to 9 2480.19 -0.280 0.610315 3 to 10 2487.85 -0.172 0.568201 4 to 11 2460.41 -0.560 0.712203 5 to 12 2501.42 0.020 0.491990 6 to 13 2554.37 0.769 0.220968 7 to 14 2460.70 -0.556 0.710812 8 to 15 2465.63 -0.486 0.686541 9 to 16 2545.39 0.642 0.260480 10 to 17 2545.67 0.646 0.259194 11 to 18 2396.76 -1.460 0.927859 12 to 19 2505.50 0.078 0.469000 13 to 20 2476.53 -0.332 0.630028 14 to 21 2555.68 0.787 0.215518 15 to 22 2453.17 -0.662 0.746112 16 to 23 2663.35 2.310 0.010439 17 to 24 2521.64 0.306 0.379785 18 to 25 2477.32 -0.321 0.625812 19 to 26 2486.74 -0.187 0.574355 20 to 27 2445.80 -0.767 0.778313 21 to 28 2490.49 -0.134 0.553488 22 to 29 2472.82 -0.384 0.649636 23 to 30 2486.66 -0.189 0.574815 24 to 31 2501.02 0.014 0.494218 25 to 32 2440.45 -0.842 0.800135 |-------------------------------------------------------------| | 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 randnumb_mt64.bin (Of 12000 tries, the average no. of successes should be 3523.0 with sigma=21.9) No. succeses z-score p-value 3491 -1.4612 0.928018 3542 0.8676 0.192812 3541 0.8219 0.205562 3539 0.7306 0.232514 3590 3.0594 0.001109 3524 0.0457 0.481790 3507 -0.7306 0.767486 3527 0.1826 0.427537 3530 0.3196 0.374623 3514 -0.4110 0.659449 Square side=100, avg. no. parked=3530.50 sample std.=25.09 p-value of the KSTEST for those 10 p-values: 0.523303 |-------------------------------------------------------------| | 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 randnumb_mt64.bin Sample no. d^2 mean equiv uni 5 1.8454 1.1986 0.843497 10 0.8065 0.8749 0.555385 15 0.0856 0.8906 0.082477 20 2.0031 0.8936 0.866438 25 0.5965 0.8397 0.450890 30 0.0896 0.7836 0.086074 35 0.1985 0.8709 0.180843 40 0.8342 0.9766 0.567612 45 1.0240 0.9372 0.642673 50 0.7772 0.9312 0.542088 55 0.8407 0.9362 0.570395 60 1.2284 0.9864 0.709041 65 4.2521 1.0165 0.986067 70 1.5336 1.0084 0.785899 75 0.3101 0.9647 0.267764 80 0.3129 0.9819 0.269791 85 0.2793 0.9603 0.244745 90 3.0462 1.0165 0.953184 95 0.0849 1.0211 0.081750 100 2.1351 1.0362 0.883026 -------------------------------------------------------------- Result of KS test on 100 transformed mindist^2's: p-value=0.448147 |-------------------------------------------------------------| | 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 randnumb_mt64.bin sample no r^3 equiv. uni. 1 114.933 0.978315 2 47.523 0.794868 3 1.929 0.062266 4 26.597 0.587930 5 1.766 0.057155 6 27.889 0.605296 7 50.575 0.814708 8 22.946 0.534597 9 20.835 0.500675 10 28.000 0.606762 11 9.462 0.270515 12 4.252 0.132134 13 78.514 0.926987 14 244.630 0.999713 15 8.156 0.238046 16 18.319 0.456988 17 15.571 0.404913 18 79.006 0.928175 19 21.877 0.517729 20 72.829 0.911754 -------------------------------------------------------------- p-value for KS test on those 20 p-values: 0.314681 |-------------------------------------------------------------| | 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 randnumb_mt64.bin Table of standardized frequency counts (obs-exp)^2/exp for j=(1,..,6), 7,...,47,(48,...) -0.1 1.3 -0.6 0.0 0.9 -0.2 1.0 0.8 0.2 -0.4 -1.4 0.2 -0.3 -1.0 1.4 1.2 0.6 0.4 0.8 -0.5 -0.5 -1.1 -0.2 -0.2 -2.2 0.2 0.2 0.2 0.3 -0.3 1.2 -0.5 -0.0 -1.6 1.6 -0.7 1.2 -0.4 -0.8 1.5 -0.6 0.0 -0.1 Chi-square with 42 degrees of freedom:31.437120 z-score=-1.152505, p-value=0.883350 _____________________________________________________________ |-------------------------------------------------------------| | 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 randnumb_mt64.bin Test no p-value 1 0.003240 2 0.003961 3 0.215563 4 0.460988 5 0.210620 6 0.570424 7 0.550444 8 0.686698 9 0.512566 10 0.047878 _____________________________________________________________ p-value for 10 kstests on 100 kstests:0.027433 |-------------------------------------------------------------| | 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 randnumb_mt64.bin (Up and down runs in a sequence of 10000 numbers) Set 1 runs up; ks test for 10 p's: 0.047776 runs down; ks test for 10 p's: 0.103935 Set 2 runs up; ks test for 10 p's: 0.827530 runs down; ks test for 10 p's: 0.175675 |-------------------------------------------------------------| |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 randnumb_mt64.bin No. of wins: Observed Expected 98766 98585.858586 z-score= 0.806, pvalue=0.21021 Analysis of Throws-per-Game: Throws Observed Expected Chisq Sum of (O-E)^2/E 1 66868 66666.7 0.608 0.608 2 37709 37654.3 0.079 0.687 3 26835 26954.7 0.532 1.219 4 19189 19313.5 0.802 2.021 5 13711 13851.4 1.424 3.445 6 9828 9943.5 1.343 4.787 7 7115 7145.0 0.126 4.914 8 5189 5139.1 0.485 5.399 9 3818 3699.9 3.772 9.171 10 2710 2666.3 0.716 9.887 11 1888 1923.3 0.649 10.536 12 1399 1388.7 0.076 10.612 13 977 1003.7 0.711 11.323 14 747 726.1 0.599 11.922 15 562 525.8 2.487 14.409 16 431 381.2 6.520 20.929 17 289 276.5 0.561 21.490 18 207 200.8 0.190 21.680 19 127 146.0 2.469 24.149 20 106 106.2 0.000 24.149 21 295 287.1 0.217 24.366 Chisq= 24.37 for 20 degrees of freedom, p= 0.22678 SUMMARY of craptest on randnumb_mt64.bin p-value for no. of wins: 0.210209 p-value for throws/game: 0.226782 _____________________________________________________________ exit Script done on Thu 30 Mar 2023 03:45:40 PM CDT