Skip to content

@Deebster /gist:1170686
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Using CRC32('5a58d67fa172d0e6d21972b8caac5e19' + n) for n = 0 .. 1000000000000
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:
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.
Segmentation fault
deebster@bernie:~/code/die.c$ ./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:
out.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 out.bin
(no_bdays=1024, no_days/yr=2^24, lambda=16.00, sample size=500)
Bits used mean chisqr p-value
1 to 24 776.21 21905.9731 0.000000
2 to 25 783.02 21905.9731 0.000000
3 to 26 807.18 21905.9731 0.000000
4 to 27 794.72 21905.9731 0.000000
5 to 28 780.60 21905.9731 0.000000
6 to 29 775.00 21905.9731 0.000000
7 to 30 796.81 21905.9731 0.000000
8 to 31 793.80 21905.9731 0.000000
9 to 32 794.29 21905.9731 0.000000
degree of freedoms is: 17
---------------------------------------------------------------
p-value for KStest on those 9 p-values: 0.000000
|-------------------------------------------------------------|
| 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=1845650.758241 with df=99; p-value= 0.000000
_______________________________________________________________
sample 2
chisquare=1850079.660671 with df=99; p-value= 0.000000
_______________________________________________________________
|-------------------------------------------------------------|
|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 out.bin
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=28 40000 211.4 7488157.097 7488157.097
r=29 0 5134.0 5134.011 7493291.107
r=30 0 23103.0 23103.048 7516394.155
r=31 0 11551.5 11551.524 7527945.678
chi-square = 7527945.678 with df = 3; p-value = 0.000
--------------------------------------------------------------
|-------------------------------------------------------------|
|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 out.bin
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=29 40000 211.4 7488157.097 7488157.097
r=30 0 5134.0 5134.011 7493291.107
r=31 0 23103.0 23103.048 7516394.155
r=32 0 11551.5 11551.524 7527945.678
chi-square = 7527945.678 with df = 3; p-value = 0.000
--------------------------------------------------------------
|-------------------------------------------------------------|
|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 out.bin
bits 1 to 8
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6248 944.3 29788.450 29788.450
r=5 93752 21743.9 238465.338 268253.788
r=6 0 77311.8 77311.800 345565.588
chi-square = 345565.588 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 2 to 9
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6249 944.3 29799.685 29799.685
r=5 93751 21743.9 238458.715 268258.399
r=6 0 77311.8 77311.800 345570.199
chi-square = 345570.199 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 3 to 10
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6237 944.3 29665.015 29665.015
r=5 93763 21743.9 238538.200 268203.215
r=6 0 77311.8 77311.800 345515.015
chi-square = 345515.015 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 4 to 11
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6304 944.3 30420.824 30420.824
r=5 93696 21743.9 238094.578 268515.402
r=6 0 77311.8 77311.800 345827.202
chi-square = 345827.202 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 5 to 12
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 7785 944.3 49555.413 49555.413
r=5 92215 21743.9 228393.983 277949.396
r=6 0 77311.8 77311.800 355261.196
chi-square = 355261.196 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 6 to 13
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 7766 944.3 49280.516 49280.516
r=5 92234 21743.9 228517.156 277797.672
r=6 0 77311.8 77311.800 355109.472
chi-square = 355109.472 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 7 to 14
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6292 944.3 30284.756 30284.756
r=5 93708 21743.9 238174.002 268458.759
r=6 0 77311.8 77311.800 345770.559
chi-square = 345770.559 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 8 to 15
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6242 944.3 29721.090 29721.090
r=5 93758 21743.9 238505.080 268226.170
r=6 0 77311.8 77311.800 345537.970
chi-square = 345537.970 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 9 to 16
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6232 944.3 29608.992 29608.992
r=5 93768 21743.9 238571.323 268180.315
r=6 0 77311.8 77311.800 345492.115
chi-square = 345492.115 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 10 to 17
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6243 944.3 29732.311 29732.311
r=5 93757 21743.9 238498.456 268230.767
r=6 0 77311.8 77311.800 345542.567
chi-square = 345542.567 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 11 to 18
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6271 944.3 30047.371 30047.371
r=5 93729 21743.9 238313.027 268360.398
r=6 0 77311.8 77311.800 345672.198
chi-square = 345672.198 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 12 to 19
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6301 944.3 30386.778 30386.778
r=5 93699 21743.9 238114.433 268501.211
r=6 0 77311.8 77311.800 345813.011
chi-square = 345813.011 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 13 to 20
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6234 944.3 29631.395 29631.395
r=5 93766 21743.9 238558.073 268189.468
r=6 0 77311.8 77311.800 345501.268
chi-square = 345501.268 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 14 to 21
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6252 944.3 29833.400 29833.400
r=5 93748 21743.9 238438.846 268272.245
r=6 0 77311.8 77311.800 345584.045
chi-square = 345584.045 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 15 to 22
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6239 944.3 29687.438 29687.438
r=5 93761 21743.9 238524.951 268212.390
r=6 0 77311.8 77311.800 345524.190
chi-square = 345524.190 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 16 to 23
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6259 944.3 29912.142 29912.142
r=5 93741 21743.9 238392.487 268304.630
r=6 0 77311.8 77311.800 345616.430
chi-square = 345616.430 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 17 to 24
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6213 944.3 29396.590 29396.590
r=5 93787 21743.9 238697.210 268093.799
r=6 0 77311.8 77311.800 345405.599
chi-square = 345405.599 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 18 to 25
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6228 944.3 29564.212 29564.212
r=5 93772 21743.9 238597.822 268162.035
r=6 0 77311.8 77311.800 345473.835
chi-square = 345473.835 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 19 to 26
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6229 944.3 29575.404 29575.404
r=5 93771 21743.9 238591.197 268166.601
r=6 0 77311.8 77311.800 345478.401
chi-square = 345478.401 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 20 to 27
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6225 944.3 29530.650 29530.650
r=5 93775 21743.9 238617.698 268148.348
r=6 0 77311.8 77311.800 345460.148
chi-square = 345460.148 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 21 to 28
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 7756 944.3 49136.140 49136.140
r=5 92244 21743.9 228581.998 277718.138
r=6 0 77311.8 77311.800 355029.938
chi-square = 355029.938 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 22 to 29
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 7741 944.3 48919.973 48919.973
r=5 92259 21743.9 228679.277 277599.250
r=6 0 77311.8 77311.800 354911.050
chi-square = 354911.050 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 23 to 30
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6277 944.3 30115.100 30115.100
r=5 93723 21743.9 238273.301 268388.402
r=6 0 77311.8 77311.800 345700.202
chi-square = 345700.202 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 24 to 31
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6234 944.3 29631.395 29631.395
r=5 93766 21743.9 238558.073 268189.468
r=6 0 77311.8 77311.800 345501.268
chi-square = 345501.268 with df = 2; p-value = 0.000
--------------------------------------------------------------
bits 25 to 32
RANK OBSERVED EXPECTED (O-E)^2/E SUM
r<=4 6247 944.3 29777.218 29777.218
r=5 93753 21743.9 238471.961 268249.180
r=6 0 77311.8 77311.800 345560.980
chi-square = 345560.980 with df = 2; p-value = 0.000
--------------------------------------------------------------
TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices
These should be 25 uniform [0,1] random variates:
0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000
The KS test for those 25 supposed UNI's yields
KS p-value = 0.000000
|-------------------------------------------------------------|
| THE BITSTREAM TEST |
|The file under test is viewed as a stream of bits. Call them |
|b1,b2,... . Consider an alphabet with two "letters", 0 and 1|
|and think of the stream of bits as a succession of 20-letter |
|"words", overlapping. Thus the first word is b1b2...b20, the|
|second is b2b3...b21, and so on. The bitstream test counts |
|the number of missing 20-letter (20-bit) words in a string of|
|2^21 overlapping 20-letter words. There are 2^20 possible 20|
|letter words. For a truly random string of 2^21+19 bits, the|
|number of missing words j should be (very close to) normally |
|distributed with mean 141,909 and sigma 428. Thus |
| (j-141909)/428 should be a standard normal variate (z score)|
|that leads to a uniform [0,1) p value. The test is repeated |
|twenty times. |
|-------------------------------------------------------------|
THE OVERLAPPING 20-TUPLES BITSTREAM TEST for out.bin
(20 bits/word, 2097152 words 20 bitstreams. No. missing words
should average 141909.33 with sigma=428.00.)
----------------------------------------------------------------
BITSTREAM test results for out.bin.
Bitstream No. missing words z-score p-value
1 257601 270.31 0.000000
2 295921 359.84 0.000000
3 224863 193.82 0.000000
4 237996 224.50 0.000000
5 300889 371.45 0.000000
6 218786 179.62 0.000000
7 218946 179.99 0.000000
8 228877 203.20 0.000000
9 211807 163.31 0.000000
10 242312 234.59 0.000000
11 223517 190.67 0.000000
12 211558 162.73 0.000000
13 254730 263.60 0.000000
14 212331 164.54 0.000000
15 214337 169.22 0.000000
16 253500 260.73 0.000000
17 278531 319.21 0.000000
18 219422 181.10 0.000000
19 218135 178.10 0.000000
20 264951 287.48 0.000000
----------------------------------------------------------------
|-------------------------------------------------------------|
| 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 out.bin
Bits used No. missing words z-score p-value
23 to 32 1034780 3078.8644 0.000000
22 to 31 1034639 3078.3782 0.000000
21 to 30 1034944 3079.4299 0.000000
20 to 29 1034474 3077.8092 0.000000
19 to 28 1034500 3077.8989 0.000000
18 to 27 1036398 3084.4437 0.000000
17 to 26 1034777 3078.8540 0.000000
16 to 25 1034818 3078.9954 0.000000
15 to 24 1034689 3078.5506 0.000000
14 to 23 1034607 3078.2678 0.000000
13 to 22 1034537 3078.0264 0.000000
12 to 21 1034503 3077.9092 0.000000
11 to 20 1034610 3078.2782 0.000000
10 to 19 1034492 3077.8713 0.000000
9 to 18 1034477 3077.8196 0.000000
8 to 17 1034523 3077.9782 0.000000
7 to 16 1034780 3078.8644 0.000000
6 to 15 1034639 3078.3782 0.000000
5 to 14 1034944 3079.4299 0.000000
4 to 13 1034474 3077.8092 0.000000
3 to 12 1034500 3077.8989 0.000000
2 to 11 1036398 3084.4437 0.000000
1 to 10 1034777 3078.8540 0.000000
-----------------------------------------------------------------
|------------------------------------------------------------ |
| 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 out.bin
Bits used No. missing words z-score p-value
28 to 32 1047243 3068.9277 0.000000
27 to 31 1047192 3068.7548 0.000000
26 to 30 1047342 3069.2633 0.000000
25 to 29 1047126 3068.5311 0.000000
24 to 28 1047009 3068.1345 0.000000
23 to 27 1047213 3068.8260 0.000000
22 to 26 1047300 3069.1209 0.000000
21 to 25 1047141 3068.5819 0.000000
20 to 24 1047297 3069.1107 0.000000
19 to 23 1047264 3068.9989 0.000000
18 to 22 1047513 3069.8429 0.000000
17 to 21 1047345 3069.2735 0.000000
16 to 20 1047345 3069.2735 0.000000
15 to 19 1047125 3068.5277 0.000000
14 to 18 1047245 3068.9345 0.000000
13 to 17 1047123 3068.5209 0.000000
12 to 16 1047243 3068.9277 0.000000
11 to 15 1047192 3068.7548 0.000000
10 to 14 1047342 3069.2633 0.000000
9 to 13 1047126 3068.5311 0.000000
8 to 12 1047009 3068.1345 0.000000
7 to 11 1047213 3068.8260 0.000000
6 to 10 1047300 3069.1209 0.000000
5 to 9 1047141 3068.5819 0.000000
4 to 8 1047297 3069.1107 0.000000
3 to 7 1047264 3068.9989 0.000000
2 to 6 1047513 3069.8429 0.000000
1 to 5 1047345 3069.2735 0.000000
-----------------------------------------------------------------
|------------------------------------------------------------ |
| 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 out.bin
Bits used No. missing words z-score p-value
31 to 32 1048460 2674.1908 0.000000
30 to 31 1048444 2674.1436 0.000000
29 to 30 1048448 2674.1554 0.000000
28 to 29 1048448 2674.1554 0.000000
27 to 28 1048448 2674.1554 0.000000
26 to 27 1048444 2674.1436 0.000000
25 to 26 1048444 2674.1436 0.000000
24 to 25 1048448 2674.1554 0.000000
23 to 24 1048444 2674.1436 0.000000
22 to 23 1048444 2674.1436 0.000000
21 to 22 1048448 2674.1554 0.000000
20 to 21 1048448 2674.1554 0.000000
19 to 20 1048448 2674.1554 0.000000
18 to 19 1048448 2674.1554 0.000000
17 to 18 1048444 2674.1436 0.000000
16 to 17 1048460 2674.1908 0.000000
15 to 16 1048460 2674.1908 0.000000
14 to 15 1048444 2674.1436 0.000000
13 to 14 1048448 2674.1554 0.000000
12 to 13 1048448 2674.1554 0.000000
11 to 12 1048448 2674.1554 0.000000
10 to 11 1048444 2674.1436 0.000000
9 to 10 1048444 2674.1436 0.000000
8 to 9 1048448 2674.1554 0.000000
7 to 8 1048444 2674.1436 0.000000
6 to 7 1048444 2674.1436 0.000000
5 to 6 1048448 2674.1554 0.000000
4 to 5 1048448 2674.1554 0.000000
3 to 4 1048448 2674.1554 0.000000
2 to 3 1048448 2674.1554 0.000000
1 to 2 1048444 2674.1436 0.000000
-----------------------------------------------------------------
|-------------------------------------------------------------|
| 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 out.bin
(Degrees of freedom: 5^4-5^3=2500; sample size: 2560000)
chisquare z-score p-value
531837.94 7485.969 0.000000
|-------------------------------------------------------------|
| This is the COUNT-THE-1''s TEST for specific bytes. |
|Consider the file under test as a stream of 32-bit integers. |
|From each integer, a specific byte is chosen , say the left- |
|most: bits 1 to 8. Each byte can contain from 0 to 8 1''s, |
|with probabilitie 1,8,28,56,70,56,28,8,1 over 256. Now let |
|the specified bytes from successive integers provide a string|
|of (overlapping) 5-letter words, each "letter" taking values |
|A,B,C,D,E. The letters are determined by the number of 1''s,|
|in that byte: 0,1,or 2 ---> A, 3 ---> B, 4 ---> C, 5 ---> D, |
|and 6,7 or 8 ---> E. Thus we have a monkey at a typewriter |
|hitting five keys with with various probabilities: 37,56,70, |
|56,37 over 256. There are 5^5 possible 5-letter words, and |
|from a string of 256,000 (overlapping) 5-letter words, counts|
|are made on the frequencies for each word. The quadratic form|
|in the weak inverse of the covariance matrix of the cell |
|counts provides a chisquare test: Q5-Q4, the difference of |
|the naive Pearson sums of (OBS-EXP)^2/EXP on counts for 5- |
|and 4-letter cell counts. |
|-------------------------------------------------------------|
Test results for specific bytes from out.bin
(Degrees of freedom: 5^4-5^3=2500; sample size: 256000)
bits used chisquare z-score p-value
1 to 8 443487.89 6236.511 0.000000
2 to 9 585000.75 8237.805 0.000000
3 to 10 463217.32 6515.527 0.000000
4 to 11 544391.37 7663.501 0.000000
5 to 12 472057.35 6640.544 0.000000
6 to 13 478001.49 6724.607 0.000000
7 to 14 446485.58 6278.904 0.000000
8 to 15 450302.02 6332.877 0.000000
9 to 16 444177.82 6246.268 0.000000
10 to 17 625034.82 8803.972 0.000000
11 to 18 941859.02 13284.543 0.000000
12 to 19 998469.58 14085.137 0.000000
13 to 20 714760.26 10072.881 0.000000
14 to 21 564968.26 7954.502 0.000000
15 to 22 1697183.13 23966.439 0.000000
16 to 23 511671.26 7200.769 0.000000
17 to 24 442834.00 6227.263 0.000000
18 to 25 586102.43 8253.385 0.000000
19 to 26 459497.91 6462.926 0.000000
20 to 27 544108.11 7659.495 0.000000
21 to 28 471147.42 6627.675 0.000000
22 to 29 477746.44 6721.000 0.000000
23 to 30 446438.58 6278.240 0.000000
24 to 31 450303.65 6332.900 0.000000
25 to 32 443768.44 6240.478 0.000000
|-------------------------------------------------------------|
| 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 out.bin
(Of 12000 tries, the average no. of successes should be
3523.0 with sigma=21.9)
No. succeses z-score p-value
427 -141.3699 1.000000
270 -148.5388 1.000000
410 -142.1461 1.000000
276 -148.2648 1.000000
278 -148.1735 1.000000
276 -148.2648 1.000000
272 -148.4475 1.000000
416 -141.8721 1.000000
433 -141.0959 1.000000
436 -140.9589 1.000000
Square side=100, avg. no. parked=349.40 sample std.=75.36
p-value of the KSTEST for those 10 p-values: 0.000000
|-------------------------------------------------------------|
| 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 out.bin
Sample no. d^2 mean equiv uni
5 0.4191 704.7770 0.343750
10 0.1862 352.4909 0.170652
15 0.4191 235.1181 0.343750
20 0.4191 176.4108 0.343750
25 0.0000 141.1789 0.000000
30 0.4191 117.6972 0.343750
35 0.1862 100.9019 0.170652
40 0.4191 88.3416 0.343750
45 0.4191 78.5579 0.343750
50 0.0000 70.7273 0.000000
55 0.4191 64.3238 0.343750
60 0.1862 58.9767 0.170652
65 0.4191 54.4722 0.343750
70 0.4191 50.6020 0.343750
75 0.0000 47.2453 0.000000
80 0.4191 44.3105 0.343750
85 0.1862 41.7160 0.170652
90 0.4191 39.4192 0.343750
95 0.4191 37.3597 0.343750
100 0.0000 35.5043 0.000000
--------------------------------------------------------------
Result of KS test on 100 transformed mindist^2's: p-value=0.000000
|-------------------------------------------------------------|
| 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 out.bin
sample no r^3 equiv. uni.
1 89.229 0.948917
2 135.744 0.989163
3 93.768 0.956090
4 46.105 0.784939
5 96.727 0.960214
6 127.389 0.985683
7 111.865 0.975979
8 105.081 0.969884
9 62.460 0.875320
10 90.388 0.950853
11 57.682 0.853794
12 54.221 0.835914
13 103.556 0.968313
14 50.021 0.811255
15 110.796 0.975107
16 92.110 0.953594
17 33.500 0.672626
18 71.398 0.907443
19 93.957 0.956365
20 101.907 0.966523
--------------------------------------------------------------
p-value for KS test on those 20 p-values: 0.000000
|-------------------------------------------------------------|
| 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 out.bin
Table of standardized frequency counts
(obs-exp)^2/exp for j=(1,..,6), 7,...,47,(48,...)
-0.1 -1.2 13.5 40.6 38.8 58.0
63.7 54.5 14.5 -5.8 -32.5 -59.8
-65.0 -58.4 22.6 109.9 147.6 -7.1
-42.4 -66.6 -66.3 -61.4 -49.3 -11.1
66.9 67.3 17.0 11.0 -6.2 -18.4
-18.4 -14.8 -11.7 -9.2 -7.2 270.6
149.5 130.6 45.5 27.0 -1.3 -1.0
-1.1
Chi-square with 42 degrees of freedom:203641.581471
z-score=22214.535561, p-value=0.000000
_____________________________________________________________
|-------------------------------------------------------------|
| 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 out.bin
Test no p-value
1 0.000000
2 0.000000
3 0.000000
4 0.000000
5 0.000000
6 0.000000
7 0.000000
8 0.000000
9 0.000000
10 0.000000
_____________________________________________________________
p-value for 10 kstests on 100 kstests:0.000000
|-------------------------------------------------------------|
| 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 out.bin
(Up and down runs in a sequence of 10000 numbers)
Set 1
runs up; ks test for 10 p's: 0.000000
runs down; ks test for 10 p's: 0.000000
Set 2
runs up; ks test for 10 p's: 0.000000
runs down; ks test for 10 p's: 0.000000
|-------------------------------------------------------------|
|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 out.bin
No. of wins: Observed Expected
144792 98585.858586
z-score=206.661, pvalue=0.00000
Analysis of Throws-per-Game:
Throws Observed Expected Chisq Sum of (O-E)^2/E
1 77556 66666.7 1778.664 1778.664
2 13850 37654.3 15048.623 16827.287
3 13973 26954.7 6252.163 23079.450
4 2054 19313.5 15423.906 38503.357
5 2436 13851.4 9407.831 47911.187
6 5251 9943.5 2214.498 50125.686
7 1265 7145.0 4838.989 54964.675
8 790 5139.1 3680.514 58645.189
9 9347 3699.9 8619.270 67264.459
10 8546 2666.3 12965.884 80230.343
11 37542 1923.3 659632.159 739862.502
12 523 1388.7 539.702 740402.204
13 915 1003.7 7.841 740410.045
14 2445 726.1 4068.740 744478.786
15 3536 525.8 17231.780 761710.566
16 6221 381.2 89476.023 851186.589
17 1696 276.5 7286.006 858472.595
18 859 200.8 2156.989 860629.584
19 584 146.0 1314.234 861943.818
20 259 106.2 219.773 862163.590
21 10352 287.1 352828.246 1214991.837
Chisq=1214991.84 for 20 degrees of freedom, p= 0.00000
SUMMARY of craptest on out.bin
p-value for no. of wins: 0.000000
p-value for throws/game: 0.000000
_____________________________________________________________
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.