seededRandom is not random at all.

These are old bug reports that have been closed.
User avatar
Wolfy
Fleet Admiral
Fleet Admiral
Posts: 5351
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

Sat Oct 12, 2013 2:49 pm

Oh, by overlaps I meant it was landing on the same point; for example if you had two at 50,50 or something like that.

I could probably rewrite it in C++ and test it after I finish some project work (dont know enough java to modify it)
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'hycrotan 'nonBinary))
Image

george moromisato
Developer
Developer
Posts: 2877
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Sat Oct 12, 2013 4:02 pm

pixelfck wrote:...
Thanks! I've changed seededRandom to use your algorithm in the next beta. It's way better now.

Meanwhile, I did a quick extension to display randomness, based on your JavaScript code: https://www.dropbox.com/s/29buowdqmeuzt ... ssTest.xml

To use it:

1. Drop the file in Extensions
2. Start a new game
3. hip's Status
4. Click on the "Randomness" menu item.

User avatar
pixelfck
Militia Captain
Militia Captain
Posts: 571
Joined: Tue Aug 11, 2009 8:47 pm
Location: Travelling around in Europe

Sat Oct 12, 2013 8:05 pm

@Wolfy: thanks! (it is javascript, not Java; so the algorithmic operators should be the same as in c++).

Anyhow, I would be interested to see what algorithm you came up with that passes all the diehard tests, I think it is quite a feat.

@george
Nice, I'll put it to good use!

~Pixelfck
Image
Download the Black Market Expansion from Xelerus.de today!
My other mods at xelerus.de

User avatar
Wolfy
Fleet Admiral
Fleet Admiral
Posts: 5351
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

Sat Oct 12, 2013 9:31 pm

Here's the results from diehard for yours (seed 123412341234 - assuming order of operations was the same)

While the rate of outlier p values (p < 0.01 or p> 0.99) was high for the number of samples (also there were two p=1.000000 values [See DNA tests for bits 32-30]), its probably sufficient levels of randomness for transcendence as well as being far faster than mine. (I tested; yours is ~3-4 orders of magnitude faster than mine)

Code: Select all

       NOTE: Most of the tests in DIEHARD return a p-value, which               
       should be uniform on [0,1) if the input file contains truly              
       independent random bits.   Those p-values are obtained by                
       p=F(X), where F is the assumed distribution of the sample                
       random variable X---often normal. But that assumed F is just             
       an asymptotic approximation, for which the fit will be worst             
       in the tails. Thus you should not be surprised with                      
       occasional p-values near 0 or 1, such as .0012 or .9983.                 
       When a bit stream really FAILS BIG, you will get p's of 0 or             
       1 to six or more places.  By all means, do not, as a                     
       Statistician might, think that a p < .025 or p> .975 means               
       that the RNG has "failed the test at the .05 level".  Such               
       p's happen among the hundreds that DIEHARD produces, even                
       with good RNG's.  So keep in mind that " p happens".                     
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::            This is the BIRTHDAY SPACINGS TEST                 ::        
     :: Choose m birthdays in a year of n days.  List the spacings    ::        
     :: between the birthdays.  If j is the number of values that     ::        
     :: occur more than once in that list, then j is asymptotically   ::        
     :: Poisson distributed with mean m^3/(4n).  Experience shows n   ::        
     :: must be quite large, say n>=2^18, for comparing the results   ::        
     :: to the Poisson distribution with that mean.  This test uses   ::        
     :: n=2^24 and m=2^9,  so that the underlying distribution for j  ::        
     :: is taken to be Poisson with lambda=2^27/(2^26)=2.  A sample   ::        
     :: of 500 j's is taken, and a chi-square goodness of fit test    ::        
     :: provides a p value.  The first test uses bits 1-24 (counting  ::        
     :: from the left) from integers in the specified file.           ::        
     ::   Then the file is closed and reopened. Next, bits 2-25 are   ::        
     :: used to provide birthdays, then 3-26 and so on to bits 9-32.  ::        
     :: Each set of bits provides a p-value, and the nine p-values    ::        
     :: provide a sample for a KSTEST.                                ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
 BIRTHDAY SPACINGS TEST, M= 512 N=2**24 LAMBDA=  2.0000
           Results for pxl_out.rbnf   
                   For a sample of size 500:     mean   
           pxl_out.rbnf    using bits  1 to 24   1.998
  duplicate       number       number 
  spacings       observed     expected
        0          63.       67.668
        1         130.      135.335
        2         151.      135.335
        3          91.       90.224
        4          40.       45.112
        5          19.       18.045
  6 to INF          6.        8.282
 Chisquare with  6 d.o.f. =     3.61 p-value=  .270802
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           pxl_out.rbnf    using bits  2 to 25   1.920
  duplicate       number       number 
  spacings       observed     expected
        0          71.       67.668
        1         148.      135.335
        2         133.      135.335
        3          84.       90.224
        4          39.       45.112
        5          18.       18.045
  6 to INF          7.        8.282
 Chisquare with  6 d.o.f. =     2.85 p-value=  .172013
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           pxl_out.rbnf    using bits  3 to 26   2.036
  duplicate       number       number 
  spacings       observed     expected
        0          66.       67.668
        1         127.      135.335
        2         144.      135.335
        3          86.       90.224
        4          48.       45.112
        5          22.       18.045
  6 to INF          7.        8.282
 Chisquare with  6 d.o.f. =     2.56 p-value=  .137990
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           pxl_out.rbnf    using bits  4 to 27   1.930
  duplicate       number       number 
  spacings       observed     expected
        0          63.       67.668
        1         149.      135.335
        2         142.      135.335
        3          79.       90.224
        4          44.       45.112
        5          19.       18.045
  6 to INF          4.        8.282
 Chisquare with  6 d.o.f. =     5.72 p-value=  .544466
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           pxl_out.rbnf    using bits  5 to 28   2.004
  duplicate       number       number 
  spacings       observed     expected
        0          63.       67.668
        1         140.      135.335
        2         135.      135.335
        3          90.       90.224
        4          46.       45.112
        5          19.       18.045
  6 to INF          7.        8.282
 Chisquare with  6 d.o.f. =      .75 p-value=  .006666
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           pxl_out.rbnf    using bits  6 to 29   2.014
  duplicate       number       number 
  spacings       observed     expected
        0          75.       67.668
        1         134.      135.335
        2         120.      135.335
        3          99.       90.224
        4          44.       45.112
        5          17.       18.045
  6 to INF         11.        8.282
 Chisquare with  6 d.o.f. =     4.38 p-value=  .374489
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           pxl_out.rbnf    using bits  7 to 30   1.988
  duplicate       number       number 
  spacings       observed     expected
        0          65.       67.668
        1         138.      135.335
        2         142.      135.335
        3          86.       90.224
        4          40.       45.112
        5          21.       18.045
  6 to INF          8.        8.282
 Chisquare with  6 d.o.f. =     1.76 p-value=  .059314
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           pxl_out.rbnf    using bits  8 to 31   1.960
  duplicate       number       number 
  spacings       observed     expected
        0          77.       67.668
        1         137.      135.335
        2         125.      135.335
        3          76.       90.224
        4          65.       45.112
        5          15.       18.045
  6 to INF          5.        8.282
 Chisquare with  6 d.o.f. =    14.92 p-value=  .979123
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           pxl_out.rbnf    using bits  9 to 32   2.056
  duplicate       number       number 
  spacings       observed     expected
        0          71.       67.668
        1         134.      135.335
        2         128.      135.335
        3          82.       90.224
        4          49.       45.112
        5          22.       18.045
  6 to INF         14.        8.282
 Chisquare with  6 d.o.f. =     6.47 p-value=  .627831
  :::::::::::::::::::::::::::::::::::::::::
   The 9 p-values were
        .270802   .172013   .137990   .544466   .006666
        .374489   .059314   .979123   .627831
  A KSTEST for the 9 p-values yields  .846869

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::            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 pxl_out.rbnf   
     For a sample of 1,000,000 consecutive 5-tuples,
 chisquare for 99 degrees of freedom= 81.249; p-value= .097134
           OPERM5 test for file pxl_out.rbnf   
     For a sample of 1,000,000 consecutive 5-tuples,
 chisquare for 99 degrees of freedom=102.731; p-value= .621446
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     :: This is the BINARY RANK TEST for 31x31 matrices. The leftmost ::        
     :: 31 bits of 31 random integers from the test sequence are used ::        
     :: to form a 31x31 binary matrix over the field {0,1}. The rank  ::        
     :: is determined. That rank can be from 0 to 31, but ranks< 28   ::        
     :: are rare, and their counts are pooled with those for rank 28. ::        
     :: Ranks are found for 40,000 such random matrices and a chisqua-::        
     :: re test is performed on counts for ranks 31,30,29 and <=28.   ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
    Binary rank test for pxl_out.rbnf   
         Rank test for 31x31 binary matrices:
        rows from leftmost 31 bits of each 32-bit integer
      rank   observed  expected (o-e)^2/e  sum
        28       194     211.4  1.435011    1.435
        29      5125    5134.0   .015813    1.451
        30     23199   23103.0   .398519    1.849
        31     11482   11551.5   .418442    2.268
  chisquare= 2.268 for 3 d. of f.; p-value= .547324
--------------------------------------------------------------
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     :: This is the BINARY RANK TEST for 32x32 matrices. A random 32x ::        
     :: 32 binary matrix is formed, each row a 32-bit random integer. ::        
     :: The rank is determined. That rank can be from 0 to 32, ranks  ::        
     :: less than 29 are rare, and their counts are pooled with those ::        
     :: for rank 29.  Ranks are found for 40,000 such random matrices ::        
     :: and a chisquare test is performed on counts for ranks  32,31, ::        
     :: 30 and <=29.                                                  ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
    Binary rank test for pxl_out.rbnf   
         Rank test for 32x32 binary matrices:
        rows from leftmost 32 bits of each 32-bit integer
      rank   observed  expected (o-e)^2/e  sum
        29       193     211.4  1.604514    1.605
        30      5222    5134.0  1.508021    3.113
        31     23159   23103.0   .135513    3.248
        32     11426   11551.5  1.364009    4.612
  chisquare= 4.612 for 3 d. of f.; p-value= .813364
--------------------------------------------------------------

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     :: This is the BINARY RANK TEST for 6x8 matrices.  From each of  ::        
     :: six random 32-bit integers from the generator under test, a   ::        
     :: specified byte is chosen, and the resulting six bytes form a  ::        
     :: 6x8 binary matrix whose rank is determined.  That rank can be ::        
     :: from 0 to 6, but ranks 0,1,2,3 are rare; their counts are     ::        
     :: pooled with those for rank 4. Ranks are found for 100,000     ::        
     :: random matrices, and a chi-square test is performed on        ::        
     :: counts for ranks 6,5 and <=4.                                 ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
         Binary Rank Test for pxl_out.rbnf   
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits  1 to  8
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          949       944.3        .023        .023
          r =5        21791     21743.9        .102        .125
          r =6        77260     77311.8        .035        .160
                        p=1-exp(-SUM/2)= .07694
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits  2 to  9
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          931       944.3        .187        .187
          r =5        21739     21743.9        .001        .188
          r =6        77330     77311.8        .004        .193
                        p=1-exp(-SUM/2)= .09187
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits  3 to 10
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          913       944.3       1.038       1.038
          r =5        21718     21743.9        .031       1.068
          r =6        77369     77311.8        .042       1.111
                        p=1-exp(-SUM/2)= .42614
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits  4 to 11
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          864       944.3       6.829       6.829
          r =5        21623     21743.9        .672       7.501
          r =6        77513     77311.8        .524       8.024
                        p=1-exp(-SUM/2)= .98191
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits  5 to 12
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          942       944.3        .006        .006
          r =5        21643     21743.9        .468        .474
          r =6        77415     77311.8        .138        .612
                        p=1-exp(-SUM/2)= .26346
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits  6 to 13
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          911       944.3       1.174       1.174
          r =5        21802     21743.9        .155       1.330
          r =6        77287     77311.8        .008       1.338
                        p=1-exp(-SUM/2)= .48767
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits  7 to 14
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          954       944.3        .100        .100
          r =5        21830     21743.9        .341        .441
          r =6        77216     77311.8        .119        .559
                        p=1-exp(-SUM/2)= .24394
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits  8 to 15
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          916       944.3        .848        .848
          r =5        21914     21743.9       1.331       2.179
          r =6        77170     77311.8        .260       2.439
                        p=1-exp(-SUM/2)= .70462
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits  9 to 16
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          971       944.3        .755        .755
          r =5        21644     21743.9        .459       1.214
          r =6        77385     77311.8        .069       1.283
                        p=1-exp(-SUM/2)= .47354
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 10 to 17
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          997       944.3       2.941       2.941
          r =5        21458     21743.9       3.759       6.700
          r =6        77545     77311.8        .703       7.404
                        p=1-exp(-SUM/2)= .97532
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 11 to 18
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          938       944.3        .042        .042
          r =5        21684     21743.9        .165        .207
          r =6        77378     77311.8        .057        .264
                        p=1-exp(-SUM/2)= .12354
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 12 to 19
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          992       944.3       2.409       2.409
          r =5        21916     21743.9       1.362       3.772
          r =6        77092     77311.8        .625       4.396
                        p=1-exp(-SUM/2)= .88900
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 13 to 20
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          935       944.3        .092        .092
          r =5        21967     21743.9       2.289       2.381
          r =6        77098     77311.8        .591       2.972
                        p=1-exp(-SUM/2)= .77372
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 14 to 21
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          957       944.3        .171        .171
          r =5        21553     21743.9       1.676       1.847
          r =6        77490     77311.8        .411       2.257
                        p=1-exp(-SUM/2)= .67656
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 15 to 22
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          921       944.3        .575        .575
          r =5        21489     21743.9       2.988       3.563
          r =6        77590     77311.8       1.001       4.564
                        p=1-exp(-SUM/2)= .89793
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 16 to 23
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          949       944.3        .023        .023
          r =5        21596     21743.9       1.006       1.029
          r =6        77455     77311.8        .265       1.295
                        p=1-exp(-SUM/2)= .47655
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 17 to 24
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          938       944.3        .042        .042
          r =5        21531     21743.9       2.085       2.127
          r =6        77531     77311.8        .621       2.748
                        p=1-exp(-SUM/2)= .74692
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 18 to 25
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          884       944.3       3.851       3.851
          r =5        21744     21743.9        .000       3.851
          r =6        77372     77311.8        .047       3.898
                        p=1-exp(-SUM/2)= .85755
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 19 to 26
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          912       944.3       1.105       1.105
          r =5        21678     21743.9        .200       1.305
          r =6        77410     77311.8        .125       1.429
                        p=1-exp(-SUM/2)= .51065
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 20 to 27
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          930       944.3        .217        .217
          r =5        21719     21743.9        .029        .245
          r =6        77351     77311.8        .020        .265
                        p=1-exp(-SUM/2)= .12409
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 21 to 28
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          926       944.3        .355        .355
          r =5        21768     21743.9        .027        .381
          r =6        77306     77311.8        .000        .382
                        p=1-exp(-SUM/2)= .17380
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 22 to 29
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          947       944.3        .008        .008
          r =5        21793     21743.9        .111        .119
          r =6        77260     77311.8        .035        .153
                        p=1-exp(-SUM/2)= .07378
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 23 to 30
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          927       944.3        .317        .317
          r =5        21900     21743.9       1.121       1.438
          r =6        77173     77311.8        .249       1.687
                        p=1-exp(-SUM/2)= .56976
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 24 to 31
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          911       944.3       1.174       1.174
          r =5        21782     21743.9        .067       1.241
          r =6        77307     77311.8        .000       1.241
                        p=1-exp(-SUM/2)= .46244
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG pxl_out.rbnf   
     b-rank test for bits 25 to 32
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          959       944.3        .229        .229
          r =5        21822     21743.9        .281        .509
          r =6        77219     77311.8        .111        .621
                        p=1-exp(-SUM/2)= .26682
   TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices
 These should be 25 uniform [0,1] random variables:
     .076937     .091875     .426136     .981907     .263455
     .487674     .243938     .704618     .473537     .975320
     .123545     .888999     .773720     .676562     .897929
     .476546     .746917     .857555     .510652     .124087
     .173801     .073785     .569763     .462444     .266816
   brank test summary for pxl_out.rbnf   
       The KS test for those 25 supposed UNI's yields
                    KS p-value= .057610

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::                   THE BITSTREAM TEST                          ::        
     :: The file under test is viewed as a stream of bits. Call them  ::        
     :: b1,b2,... .  Consider an alphabet with two "letters", 0 and 1 ::        
     :: and think of the stream of bits as a succession of 20-letter  ::        
     :: "words", overlapping.  Thus the first word is b1b2...b20, the ::        
     :: second is b2b3...b21, and so on.  The bitstream test counts   ::        
     :: the number of missing 20-letter (20-bit) words in a string of ::        
     :: 2^21 overlapping 20-letter words.  There are 2^20 possible 20 ::        
     :: letter words.  For a truly random string of 2^21+19 bits, the ::        
     :: number of missing words j should be (very close to) normally  ::        
     :: distributed with mean 141,909 and sigma 428.  Thus            ::        
     ::  (j-141909)/428 should be a standard normal variate (z score) ::        
     :: that leads to a uniform [0,1) p value.  The test is repeated  ::        
     :: twenty times.                                                 ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
 THE OVERLAPPING 20-tuples BITSTREAM  TEST, 20 BITS PER WORD, N words
   This test uses N=2^21 and samples the bitstream 20 times.
  No. missing words should average  141909. with sigma=428.
---------------------------------------------------------
 tst no  1:  142375 missing words,    1.09 sigmas from mean, p-value= .86171
 tst no  2:  141977 missing words,     .16 sigmas from mean, p-value= .56282
 tst no  3:  142098 missing words,     .44 sigmas from mean, p-value= .67033
 tst no  4:  142733 missing words,    1.92 sigmas from mean, p-value= .97285
 tst no  5:  142001 missing words,     .21 sigmas from mean, p-value= .58480
 tst no  6:  142032 missing words,     .29 sigmas from mean, p-value= .61280
 tst no  7:  142444 missing words,    1.25 sigmas from mean, p-value= .89421
 tst no  8:  141918 missing words,     .02 sigmas from mean, p-value= .50808
 tst no  9:  141131 missing words,   -1.82 sigmas from mean, p-value= .03449
 tst no 10:  141558 missing words,    -.82 sigmas from mean, p-value= .20586
 tst no 11:  141643 missing words,    -.62 sigmas from mean, p-value= .26688
 tst no 12:  141339 missing words,   -1.33 sigmas from mean, p-value= .09134
 tst no 13:  142243 missing words,     .78 sigmas from mean, p-value= .78219
 tst no 14:  141973 missing words,     .15 sigmas from mean, p-value= .55913
 tst no 15:  142963 missing words,    2.46 sigmas from mean, p-value= .99309
 tst no 16:  142042 missing words,     .31 sigmas from mean, p-value= .62171
 tst no 17:  141591 missing words,    -.74 sigmas from mean, p-value= .22851
 tst no 18:  142126 missing words,     .51 sigmas from mean, p-value= .69366
 tst no 19:  141795 missing words,    -.27 sigmas from mean, p-value= .39469
 tst no 20:  141858 missing words,    -.12 sigmas from mean, p-value= .45227

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::             The tests OPSO, OQSO and DNA                      ::        
     ::         OPSO means Overlapping-Pairs-Sparse-Occupancy         ::        
     :: The OPSO test considers 2-letter words from an alphabet of    ::        
     :: 1024 letters.  Each letter is determined by a specified ten   ::        
     :: bits from a 32-bit integer in the sequence to be tested. OPSO ::        
     :: generates  2^21 (overlapping) 2-letter words  (from 2^21+1    ::        
     :: "keystrokes")  and counts the number of missing words---that  ::        
     :: is 2-letter words which do not appear in the entire sequence. ::        
     :: That count should be very close to normally distributed with  ::        
     :: mean 141,909, sigma 290. Thus (missingwrds-141909)/290 should ::        
     :: be a standard normal variable. The OPSO test takes 32 bits at ::        
     :: a time from the test file and uses a designated set of ten    ::        
     :: consecutive bits. It then restarts the file for the next de-  ::        
     :: signated 10 bits, and so on.                                  ::        
     ::                                                               ::        
     ::     OQSO means Overlapping-Quadruples-Sparse-Occupancy        ::        
     ::   The test OQSO is similar, except that it considers 4-letter ::        
     :: words from an alphabet of 32 letters, each letter determined  ::        
     :: by a designated string of 5 consecutive bits from the test    ::        
     :: file, elements of which are assumed 32-bit random integers.   ::        
     :: The mean number of missing words in a sequence of 2^21 four-  ::        
     :: letter words,  (2^21+3 "keystrokes"), is again 141909, with   ::        
     :: sigma = 295.  The mean is based on theory; sigma comes from   ::        
     :: extensive simulation.                                         ::        
     ::                                                               ::        
     ::    The DNA test considers an alphabet of 4 letters::  C,G,A,T,::        
     :: determined by two designated bits in the sequence of random   ::        
     :: integers being tested.  It considers 10-letter words, so that ::        
     :: as in OPSO and OQSO, there are 2^20 possible words, and the   ::        
     :: mean number of missing words from a string of 2^21  (over-    ::        
     :: lapping)  10-letter  words (2^21+9 "keystrokes") is 141909.   ::        
     :: The standard deviation sigma=339 was determined as for OQSO   ::        
     :: by simulation.  (Sigma for OPSO, 290, is the true value (to   ::        
     :: three places), not determined by simulation.                  ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
 OPSO test for generator pxl_out.rbnf   
  Output: No. missing words (mw), equiv normal variate (z), p-value (p)
                                                           mw     z     p
    OPSO for pxl_out.rbnf    using bits 23 to 32        142170   .899  .8156
    OPSO for pxl_out.rbnf    using bits 22 to 31        141836  -.253  .4002
    OPSO for pxl_out.rbnf    using bits 21 to 30        141805  -.360  .3595
    OPSO for pxl_out.rbnf    using bits 20 to 29        142079   .585  .7208
    OPSO for pxl_out.rbnf    using bits 19 to 28        142195   .985  .8377
    OPSO for pxl_out.rbnf    using bits 18 to 27        141534 -1.294  .0978
    OPSO for pxl_out.rbnf    using bits 17 to 26        142044   .464  .6788
    OPSO for pxl_out.rbnf    using bits 16 to 25        142158   .857  .8044
    OPSO for pxl_out.rbnf    using bits 15 to 24        141648  -.901  .1838
    OPSO for pxl_out.rbnf    using bits 14 to 23        141405 -1.739  .0410
    OPSO for pxl_out.rbnf    using bits 13 to 22        141582 -1.129  .1295
    OPSO for pxl_out.rbnf    using bits 12 to 21        142001   .316  .6240
    OPSO for pxl_out.rbnf    using bits 11 to 20        141936   .092  .5366
    OPSO for pxl_out.rbnf    using bits 10 to 19        142088   .616  .7311
    OPSO for pxl_out.rbnf    using bits  9 to 18        141839  -.243  .4042
    OPSO for pxl_out.rbnf    using bits  8 to 17        141888  -.074  .4707
    OPSO for pxl_out.rbnf    using bits  7 to 16        142163   .875  .8091
    OPSO for pxl_out.rbnf    using bits  6 to 15        141597 -1.077  .1407
    OPSO for pxl_out.rbnf    using bits  5 to 14        141966   .195  .5775
    OPSO for pxl_out.rbnf    using bits  4 to 13        142254  1.189  .8827
    OPSO for pxl_out.rbnf    using bits  3 to 12        142377  1.613  .9466
    OPSO for pxl_out.rbnf    using bits  2 to 11        141916   .023  .5092
    OPSO for pxl_out.rbnf    using bits  1 to 10        141579 -1.139  .1273
 OQSO test for generator pxl_out.rbnf   
  Output: No. missing words (mw), equiv normal variate (z), p-value (p)
                                                           mw     z     p
    OQSO for pxl_out.rbnf    using bits 28 to 32        142194   .965  .8327
    OQSO for pxl_out.rbnf    using bits 27 to 31        142041   .446  .6723
    OQSO for pxl_out.rbnf    using bits 26 to 30        141826  -.282  .3888
    OQSO for pxl_out.rbnf    using bits 25 to 29        141467 -1.499  .0669
    OQSO for pxl_out.rbnf    using bits 24 to 28        141725  -.625  .2660
    OQSO for pxl_out.rbnf    using bits 23 to 27        142053   .487  .6869
    OQSO for pxl_out.rbnf    using bits 22 to 26        141978   .233  .5920
    OQSO for pxl_out.rbnf    using bits 21 to 25        142068   .538  .7047
    OQSO for pxl_out.rbnf    using bits 20 to 24        142175   .901  .8161
    OQSO for pxl_out.rbnf    using bits 19 to 23        141648  -.886  .1878
    OQSO for pxl_out.rbnf    using bits 18 to 22        141993   .284  .6117
    OQSO for pxl_out.rbnf    using bits 17 to 21        142200   .985  .8378
    OQSO for pxl_out.rbnf    using bits 16 to 20        142035   .426  .6649
    OQSO for pxl_out.rbnf    using bits 15 to 19        141482 -1.449  .0737
    OQSO for pxl_out.rbnf    using bits 14 to 18        141736  -.588  .2784
    OQSO for pxl_out.rbnf    using bits 13 to 17        142196   .972  .8344
    OQSO for pxl_out.rbnf    using bits 12 to 16        141593 -1.072  .1418
    OQSO for pxl_out.rbnf    using bits 11 to 15        141317 -2.008  .0223
    OQSO for pxl_out.rbnf    using bits 10 to 14        141444 -1.577  .0574
    OQSO for pxl_out.rbnf    using bits  9 to 13        142662  2.551  .9946
    OQSO for pxl_out.rbnf    using bits  8 to 12        142596  2.328  .9900
    OQSO for pxl_out.rbnf    using bits  7 to 11        142165   .867  .8069
    OQSO for pxl_out.rbnf    using bits  6 to 10        142339  1.457  .9274
    OQSO for pxl_out.rbnf    using bits  5 to  9        141519 -1.323  .0929
    OQSO for pxl_out.rbnf    using bits  4 to  8        141804  -.357  .3605
    OQSO for pxl_out.rbnf    using bits  3 to  7        141734  -.594  .2761
    OQSO for pxl_out.rbnf    using bits  2 to  6        141803  -.360  .3593
    OQSO for pxl_out.rbnf    using bits  1 to  5        141243 -2.259  .0119
  DNA test for generator pxl_out.rbnf   
  Output: No. missing words (mw), equiv normal variate (z), p-value (p)
                                                           mw     z     p
     DNA for pxl_out.rbnf    using bits 31 to 32        145144  9.542 1.0000
     DNA for pxl_out.rbnf    using bits 30 to 31        143875  5.798 1.0000
     DNA for pxl_out.rbnf    using bits 29 to 30        142390  1.418  .9219
     DNA for pxl_out.rbnf    using bits 28 to 29        142277  1.085  .8609
     DNA for pxl_out.rbnf    using bits 27 to 28        142144   .692  .7556
     DNA for pxl_out.rbnf    using bits 26 to 27        142371  1.362  .9134
     DNA for pxl_out.rbnf    using bits 25 to 26        141998   .262  .6032
     DNA for pxl_out.rbnf    using bits 24 to 25        141948   .114  .5454
     DNA for pxl_out.rbnf    using bits 23 to 24        141560 -1.030  .1514
     DNA for pxl_out.rbnf    using bits 22 to 23        141927   .052  .5208
     DNA for pxl_out.rbnf    using bits 21 to 22        142071   .477  .6833
     DNA for pxl_out.rbnf    using bits 20 to 21        141631  -.821  .2058
     DNA for pxl_out.rbnf    using bits 19 to 20        142239   .972  .8346
     DNA for pxl_out.rbnf    using bits 18 to 19        142113   .601  .7260
     DNA for pxl_out.rbnf    using bits 17 to 18        142182   .804  .7894
     DNA for pxl_out.rbnf    using bits 16 to 17        142296  1.141  .8730
     DNA for pxl_out.rbnf    using bits 15 to 16        141620  -.853  .1967
     DNA for pxl_out.rbnf    using bits 14 to 15        141755  -.455  .3245
     DNA for pxl_out.rbnf    using bits 13 to 14        142224   .928  .8234
     DNA for pxl_out.rbnf    using bits 12 to 13        141150 -2.240  .0125
     DNA for pxl_out.rbnf    using bits 11 to 12        142648  2.179  .9853
     DNA for pxl_out.rbnf    using bits 10 to 11        142009   .294  .6156
     DNA for pxl_out.rbnf    using bits  9 to 10        142114   .604  .7270
     DNA for pxl_out.rbnf    using bits  8 to  9        142300  1.152  .8754
     DNA for pxl_out.rbnf    using bits  7 to  8        142361  1.332  .9086
     DNA for pxl_out.rbnf    using bits  6 to  7        142144   .692  .7556
     DNA for pxl_out.rbnf    using bits  5 to  6        142193   .837  .7986
     DNA for pxl_out.rbnf    using bits  4 to  5        141593  -.933  .1754
     DNA for pxl_out.rbnf    using bits  3 to  4        141863  -.137  .4456
     DNA for pxl_out.rbnf    using bits  2 to  3        141599  -.915  .1800
     DNA for pxl_out.rbnf    using bits  1 to  2        141740  -.499  .3087

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::     This is the COUNT-THE-1's TEST on a stream of bytes.      ::        
     :: Consider the file under test as a stream of bytes (four per   ::        
     :: 32 bit integer).  Each byte can contain from 0 to 8 1's,      ::        
     :: with probabilities 1,8,28,56,70,56,28,8,1 over 256.  Now let  ::        
     :: the stream of bytes provide a string of overlapping  5-letter ::        
     :: words, each "letter" taking values A,B,C,D,E. The letters are ::        
     :: determined by the number of 1's in a byte::  0,1,or 2 yield A,::        
     :: 3 yields B, 4 yields C, 5 yields D and 6,7 or 8 yield E. Thus ::        
     :: we have a monkey at a typewriter hitting five keys with vari- ::        
     :: ous probabilities (37,56,70,56,37 over 256).  There are 5^5   ::        
     :: possible 5-letter words, and from a string of 256,000 (over-  ::        
     :: lapping) 5-letter words, counts are made on the frequencies   ::        
     :: for each word.   The quadratic form in the weak inverse of    ::        
     :: the covariance matrix of the cell counts provides a chisquare ::        
     :: test::  Q5-Q4, the difference of the naive Pearson sums of    ::        
     :: (OBS-EXP)^2/EXP on counts for 5- and 4-letter cell counts.    ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
   Test results for pxl_out.rbnf   
 Chi-square with 5^5-5^4=2500 d.of f. for sample size:2560000
                               chisquare  equiv normal  p-value
  Results fo COUNT-THE-1's in successive bytes:
 byte stream for pxl_out.rbnf     2503.60       .051      .520298
 byte stream for pxl_out.rbnf     2499.89      -.002      .499391

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::     This is the COUNT-THE-1's TEST for specific bytes.        ::        
     :: Consider the file under test as a stream of 32-bit integers.  ::        
     :: From each integer, a specific byte is chosen , say the left-  ::        
     :: most::  bits 1 to 8. Each byte can contain from 0 to 8 1's,   ::        
     :: with probabilitie 1,8,28,56,70,56,28,8,1 over 256.  Now let   ::        
     :: the specified bytes from successive integers provide a string ::        
     :: of (overlapping) 5-letter words, each "letter" taking values  ::        
     :: A,B,C,D,E. The letters are determined  by the number of 1's,  ::        
     :: in that byte::  0,1,or 2 ---> A, 3 ---> B, 4 ---> C, 5 ---> D,::        
     :: and  6,7 or 8 ---> E.  Thus we have a monkey at a typewriter  ::        
     :: hitting five keys with with various probabilities::  37,56,70,::        
     :: 56,37 over 256. There are 5^5 possible 5-letter words, and    ::        
     :: from a string of 256,000 (overlapping) 5-letter words, counts ::        
     :: are made on the frequencies for each word. The quadratic form ::        
     :: in the weak inverse of the covariance matrix of the cell      ::        
     :: counts provides a chisquare test::  Q5-Q4, the difference of  ::        
     :: the naive Pearson  sums of (OBS-EXP)^2/EXP on counts for 5-   ::        
     :: and 4-letter cell counts.                                     ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
 Chi-square with 5^5-5^4=2500 d.of f. for sample size: 256000
                      chisquare  equiv normal  p value
  Results for COUNT-THE-1's in specified bytes:
           bits  1 to  8  2649.09      2.108      .982505
           bits  2 to  9  2464.47      -.502      .307691
           bits  3 to 10  2508.01       .113      .545073
           bits  4 to 11  2459.82      -.568      .284947
           bits  5 to 12  2531.40       .444      .671514
           bits  6 to 13  2533.45       .473      .681897
           bits  7 to 14  2427.66     -1.023      .153138
           bits  8 to 15  2495.70      -.061      .475736
           bits  9 to 16  2525.30       .358      .639753
           bits 10 to 17  2483.34      -.236      .406858
           bits 11 to 18  2493.98      -.085      .466052
           bits 12 to 19  2525.69       .363      .641815
           bits 13 to 20  2491.37      -.122      .451442
           bits 14 to 21  2684.34      2.607      .995433
           bits 15 to 22  2664.91      2.332      .990153
           bits 16 to 23  2526.33       .372      .645175
           bits 17 to 24  2549.44       .699      .757781
           bits 18 to 25  2493.49      -.092      .463333
           bits 19 to 26  2633.46      1.887      .970447
           bits 20 to 27  2556.29       .796      .787002
           bits 21 to 28  2423.79     -1.078      .140572
           bits 22 to 29  2559.75       .845      .800959
           bits 23 to 30  2579.56      1.125      .869725
           bits 24 to 31  2425.69     -1.051      .146651
           bits 25 to 32  2431.76      -.965      .167257

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::               THIS IS A PARKING LOT TEST                      ::        
     :: In a square of side 100, randomly "park" a car---a circle of  ::        
     :: radius 1.   Then try to park a 2nd, a 3rd, and so on, each    ::        
     :: time parking "by ear".  That is, if an attempt to park a car  ::        
     :: causes a crash with one already parked, try again at a new    ::        
     :: random location. (To avoid path problems, consider parking    ::        
     :: helicopters rather than cars.)   Each attempt leads to either ::        
     :: a crash or a success, the latter followed by an increment to  ::        
     :: the list of cars already parked. If we plot n:  the number of ::        
     :: attempts, versus k::  the number successfully parked, we get a::        
     :: curve that should be similar to those provided by a perfect   ::        
     :: random number generator.  Theory for the behavior of such a   ::        
     :: random curve seems beyond reach, and as graphics displays are ::        
     :: not available for this battery of tests, a simple characteriz ::        
     :: ation of the random experiment is used: k, the number of cars ::        
     :: successfully parked after n=12,000 attempts. Simulation shows ::        
     :: that k should average 3523 with sigma 21.9 and is very close  ::        
     :: to normally distributed.  Thus (k-3523)/21.9 should be a st-  ::        
     :: andard normal variable, which, converted to a uniform varia-  ::        
     :: ble, provides input to a KSTEST based on a sample of 10.      ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
           CDPARK: result of ten tests on file pxl_out.rbnf   
            Of 12,000 tries, the average no. of successes
                 should be 3523 with sigma=21.9
            Successes: 3558    z-score:  1.598 p-value: .944998
            Successes: 3522    z-score:  -.046 p-value: .481790
            Successes: 3533    z-score:   .457 p-value: .676028
            Successes: 3560    z-score:  1.689 p-value: .954438
            Successes: 3548    z-score:  1.142 p-value: .873180
            Successes: 3477    z-score: -2.100 p-value: .017844
            Successes: 3525    z-score:   .091 p-value: .536382
            Successes: 3544    z-score:   .959 p-value: .831196
            Successes: 3504    z-score:  -.868 p-value: .192812
            Successes: 3528    z-score:   .228 p-value: .590298
 
           square size   avg. no.  parked   sample sigma
             100.            3529.900       24.058
            KSTEST for the above 10: p=  .676456

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::               THE MINIMUM DISTANCE TEST                       ::        
     :: It does this 100 times::   choose n=8000 random points in a   ::        
     :: square of side 10000.  Find d, the minimum distance between   ::        
     :: the (n^2-n)/2 pairs of points.  If the points are truly inde- ::        
     :: pendent uniform, then d^2, the square of the minimum distance ::        
     :: should be (very close to) exponentially distributed with mean ::        
     :: .995 .  Thus 1-exp(-d^2/.995) should be uniform on [0,1) and  ::        
     :: a KSTEST on the resulting 100 values serves as a test of uni- ::        
     :: formity for random points in the square. Test numbers=0 mod 5 ::        
     :: are printed but the KSTEST is based on the full set of 100    ::        
     :: random choices of 8000 points in the 10000x10000 square.      ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
               This is the MINIMUM DISTANCE test
              for random integers in the file pxl_out.rbnf   
     Sample no.    d^2     avg     equiv uni            
           5     .4158    .5669     .341561
          10     .6495    .7930     .479413
          15    1.4765    .9208     .773248
          20     .1684    .8054     .155709
          25     .8864    .7717     .589707
          30     .1966    .7591     .179272
          35     .5151    .7458     .404086
          40     .2314    .6891     .207473
          45    1.5354    .7787     .786285
          50     .3581    .7369     .302228
          55    2.1589    .7722     .885796
          60     .7537    .7463     .531158
          65     .5487    .7249     .423875
          70     .3815    .7405     .318455
          75     .4195    .7450     .343980
          80     .2645    .7724     .233401
          85    1.5017    .8094     .778917
          90     .3021    .8095     .261850
          95     .5573    .7981     .428828
         100     .4472    .8611     .361995
     MINIMUM DISTANCE TEST for pxl_out.rbnf   
          Result of KS test on 20 transformed mindist^2's:
                                  p-value= .777127

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::              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 pxl_out.rbnf   
 sample no:  1     r^3=  62.595     p-value= .87588
 sample no:  2     r^3=   9.175     p-value= .26349
 sample no:  3     r^3=    .822     p-value= .02704
 sample no:  4     r^3=   1.004     p-value= .03291
 sample no:  5     r^3=   6.329     p-value= .19021
 sample no:  6     r^3=  26.698     p-value= .58931
 sample no:  7     r^3=  31.373     p-value= .64857
 sample no:  8     r^3=  59.190     p-value= .86096
 sample no:  9     r^3=   6.742     p-value= .20128
 sample no: 10     r^3=  15.087     p-value= .39522
 sample no: 11     r^3=   4.257     p-value= .13229
 sample no: 12     r^3=  37.958     p-value= .71783
 sample no: 13     r^3=  18.202     p-value= .45487
 sample no: 14     r^3=  44.742     p-value= .77494
 sample no: 15     r^3=  66.820     p-value= .89218
 sample no: 16     r^3=  99.728     p-value= .96400
 sample no: 17     r^3=  17.679     p-value= .44528
 sample no: 18     r^3=   3.214     p-value= .10161
 sample no: 19     r^3=  58.317     p-value= .85686
 sample no: 20     r^3=   6.864     p-value= .20450
  A KS test is applied to those 20 p-values.
---------------------------------------------------------
       3DSPHERES test for file pxl_out.rbnf         p-value= .161536
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::      This is the SQEEZE test                                  ::        
     ::  Random integers are floated to get uniforms on [0,1). Start- ::        
     ::  ing with k=2^31=2147483647, the test finds j, the number of  ::        
     ::  iterations necessary to reduce k to 1, using the reduction   ::        
     ::  k=ceiling(k*U), with U provided by floating integers from    ::        
     ::  the file being tested.  Such j's are found 100,000 times,    ::        
     ::  then counts for the number of times j was <=6,7,...,47,>=48  ::        
     ::  are used to provide a chi-square test for cell frequencies.  ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
            RESULTS OF SQUEEZE TEST FOR pxl_out.rbnf   
         Table of standardized frequency counts
     ( (obs-exp)/sqrt(exp) )^2
        for j taking values <=6,7,8,...,47,>=48:
     -.1     -.3      .1      .2     -.3      .7
      .1      .2    -1.7      .8     -.3      .6
     -.3      .7     -.8     -.4     2.5      .8
      .7     -.7    -3.0     1.0      .2      .6
     -.2      .0    -1.5     -.5    -1.5      .2
      .1    -1.4     -.1      .4     1.6     -.5
     -.7     1.5     -.8     1.5    -1.3    -1.0
    -1.1
           Chi-square with 42 degrees of freedom: 43.397
              z-score=   .152  p-value= .588427
______________________________________________________________

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::             The  OVERLAPPING SUMS test                        ::        
     :: Integers are floated to get a sequence U(1),U(2),... of uni-  ::        
     :: form [0,1) variables.  Then overlapping sums,                 ::        
     ::   S(1)=U(1)+...+U(100), S2=U(2)+...+U(101),... are formed.    ::        
     :: The S's are virtually normal with a certain covariance mat-   ::        
     :: rix.  A linear transformation of the S's converts them to a   ::        
     :: sequence of independent standard normals, which are converted ::        
     :: to uniform variables for a KSTEST. The  p-values from ten     ::        
     :: KSTESTs are given still another KSTEST.                       ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
                Test no.  1      p-value  .471938
                Test no.  2      p-value  .661696
                Test no.  3      p-value  .127312
                Test no.  4      p-value  .138076
                Test no.  5      p-value  .252853
                Test no.  6      p-value  .966210
                Test no.  7      p-value  .981441
                Test no.  8      p-value  .961647
                Test no.  9      p-value  .877290
                Test no. 10      p-value  .974672
   Results of the OSUM test for pxl_out.rbnf   
        KSTEST on the above 10 p-values:  .974109

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::     This is the RUNS test.  It counts runs up, and runs down, ::        
     :: in a sequence of uniform [0,1) variables, obtained by float-  ::        
     :: ing the 32-bit integers in the specified file. This example   ::        
     :: shows how runs are counted:  .123,.357,.789,.425,.224,.416,.95::        
     :: contains an up-run of length 3, a down-run of length 2 and an ::        
     :: up-run of (at least) 2, depending on the next values.  The    ::        
     :: covariance matrices for the runs-up and runs-down are well    ::        
     :: known, leading to chisquare tests for quadratic forms in the  ::        
     :: weak inverses of the covariance matrices.  Runs are counted   ::        
     :: for sequences of length 10,000.  This is done ten times. Then ::        
     :: repeated.                                                     ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
           The RUNS test for file pxl_out.rbnf   
     Up and down runs in a sample of 10000
_________________________________________________ 
                 Run test for pxl_out.rbnf   :
       runs up; ks test for 10 p's: .137403
     runs down; ks test for 10 p's: .458294
                 Run test for pxl_out.rbnf   :
       runs up; ks test for 10 p's: .896885
     runs down; ks test for 10 p's: .347245

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     :: This is the CRAPS TEST. It plays 200,000 games of craps, finds::        
     :: the number of wins and the number of throws necessary to end  ::        
     :: each game.  The number of wins should be (very close to) a    ::        
     :: normal with mean 200000p and variance 200000p(1-p), with      ::        
     :: p=244/495.  Throws necessary to complete the game can vary    ::        
     :: from 1 to infinity, but counts for all>21 are lumped with 21. ::        
     :: A chi-square test is made on the no.-of-throws cell counts.   ::        
     :: Each 32-bit integer from the test file provides the value for ::        
     :: the throw of a die, by floating to [0,1), multiplying by 6    ::        
     :: and taking 1 plus the integer part of the result.             ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
                Results of craps test for pxl_out.rbnf   
  No. of wins:  Observed Expected
                                98448    98585.86
                  98448= No. of wins, z-score= -.617 pvalue= .26875
   Analysis of Throws-per-Game:
 Chisq=  25.52 for 20 degrees of freedom, p=  .81772
               Throws Observed Expected  Chisq     Sum
                  1    66332    66666.7   1.680    1.680
                  2    37909    37654.3   1.723    3.403
                  3    26940    26954.7    .008    3.411
                  4    19418    19313.5    .566    3.976
                  5    13744    13851.4    .833    4.810
                  6     9937     9943.5    .004    4.814
                  7     7026     7145.0   1.983    6.797
                  8     5303     5139.1   5.229   12.026
                  9     3782     3699.9   1.823   13.849
                 10     2708     2666.3    .652   14.501
                 11     1929     1923.3    .017   14.518
                 12     1352     1388.7    .972   15.490
                 13     1015     1003.7    .127   15.617
                 14      708      726.1    .453   16.070
                 15      529      525.8    .019   16.089
                 16      373      381.2    .174   16.263
                 17      244      276.5   3.829   20.092
                 18      179      200.8   2.373   22.465
                 19      157      146.0    .831   23.296
                 20      121      106.2   2.058   25.354
                 21      294      287.1    .165   25.519
            SUMMARY  FOR pxl_out.rbnf   
                p-value for no. of wins: .268753
                p-value for throws/game: .817722

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

 Results of DIEHARD battery of tests sent to file pxl_out.txt    
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'hycrotan 'nonBinary))
Image

User avatar
Wolfy
Fleet Admiral
Fleet Admiral
Posts: 5351
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

Sat Oct 12, 2013 10:03 pm

also heres the mk3b algorithm I used (super slow though) - the different versions were just slight refinements that lowered the number of (0.5-|p-0.5|) < 1% - it also seems that 123412341234 is a particularly rough seed:

statistics from the different versions:
mk1: normP < 1% = 5 ____ normP < 0.1% = 2
mk2: (didnt test, had a bug so just redid the part)
mk3: nomrP < 1% = 4 ____ normP < 0.1% = 3 (total number of outliers went down.. but the outliers got worse..)
mk3b: normP < 1% = 2 _____ normP < 0.1% = 0 (Reasonable results given the number of tests - also one was P=0.009.. so barely fell in that category at that..)

this one was slightly edited to run in C# so I could play around with doing some image stuff but I decided not to and just work on my class project instead >.>

Its extremely slow (~60-70kb/s) - (this is the mk3b)

Code: Select all

                    unchecked
                    {
                        rdnm = 0;
                        ulong[] p = new ulong[128];
                        for (int k = 0; k < 8; k++)
                        {
                            nseed = 784579452832475417 * seed + 599874909874320983;
                            ulong s = 0;
                            for (int j = 0; j < 128; j++)
                            {
                                p[j] = nseed;
                                nseed = (nseed * (ulong)j + nseed % 1200) * 499885209843298032;
                                nseed = cseed + nseed >> 5;
                                qseed = 423109432143 * cseed;
                                if (1 == (nseed & 0x01))
                                {
                                    nseed -= (fseed >> 5) * (cseed);
                                    p[j] += qseed * (ulong)j + cseed;
                                    p[j] -= nseed * p[j] + 9839403928324 * ((qseed >> 5) % 117);
                                }
                                else
                                {
                                    nseed += (cseed >> 10);
                                    p[j] += qseed * (ulong)j - cseed;
                                    p[j] += nseed * p[j] - 9839403928324 * ((qseed >> 5) % 117);
                                }
                                if ((ulong)j < (cseed % 127) || j == 117)
                                {
                                    cseed = p[j] * fseed * cseed;
                                    cseed += nseed;
                                }
                                s += p[j];
                                nseed -= qseed * 23498900909821;
                                qseed = 23439802347 * qseed + 74587924370984;
                            }
                            seed = nseed * qseed + cseed;
                            s = s * (nseed >> (char)(qseed % 3 + 1)) + (qseed + (cseed >> (char)(p[7] % 5 +1 )));
                            if (seed == lseed)
                            {
                                seed = 324897329807 * seed + qseed >> 4;
                                k--;
                            }
                            else
                            {
                                lseed = seed;
                                rdnm = (rdnm << 8) + (s >> (64 - 8));
                            }
                        }
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'hycrotan 'nonBinary))
Image

User avatar
Wolfy
Fleet Admiral
Fleet Admiral
Posts: 5351
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

Sun Oct 13, 2013 12:29 am

Ok, so for fun (since I already know the standard c rand() function is awful I didnt bother to test it) I decided to try out the simple .net rng...

Turns out that pixels knocks it flat (with around the same runtime!) - even with its own two 1.0's, the standard .net one is... just look at it! The number of 1.000000's is... This is without a doubt a complete fail.

Code: Select all

       NOTE: Most of the tests in DIEHARD return a p-value, which               
       should be uniform on [0,1) if the input file contains truly              
       independent random bits.   Those p-values are obtained by                
       p=F(X), where F is the assumed distribution of the sample                
       random variable X---often normal. But that assumed F is just             
       an asymptotic approximation, for which the fit will be worst             
       in the tails. Thus you should not be surprised with                      
       occasional p-values near 0 or 1, such as .0012 or .9983.                 
       When a bit stream really FAILS BIG, you will get p's of 0 or             
       1 to six or more places.  By all means, do not, as a                     
       Statistician might, think that a p < .025 or p> .975 means               
       that the RNG has "failed the test at the .05 level".  Such               
       p's happen among the hundreds that DIEHARD produces, even                
       with good RNG's.  So keep in mind that " p happens".                     
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::            This is the BIRTHDAY SPACINGS TEST                 ::        
     :: Choose m birthdays in a year of n days.  List the spacings    ::        
     :: between the birthdays.  If j is the number of values that     ::        
     :: occur more than once in that list, then j is asymptotically   ::        
     :: Poisson distributed with mean m^3/(4n).  Experience shows n   ::        
     :: must be quite large, say n>=2^18, for comparing the results   ::        
     :: to the Poisson distribution with that mean.  This test uses   ::        
     :: n=2^24 and m=2^9,  so that the underlying distribution for j  ::        
     :: is taken to be Poisson with lambda=2^27/(2^26)=2.  A sample   ::        
     :: of 500 j's is taken, and a chi-square goodness of fit test    ::        
     :: provides a p value.  The first test uses bits 1-24 (counting  ::        
     :: from the left) from integers in the specified file.           ::        
     ::   Then the file is closed and reopened. Next, bits 2-25 are   ::        
     :: used to provide birthdays, then 3-26 and so on to bits 9-32.  ::        
     :: Each set of bits provides a p-value, and the nine p-values    ::        
     :: provide a sample for a KSTEST.                                ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
 BIRTHDAY SPACINGS TEST, M= 512 N=2**24 LAMBDA=  2.0000
           Results for net_out.rbnf   
                   For a sample of size 500:     mean   
           net_out.rbnf    using bits  1 to 24   5.122
  duplicate       number       number 
  spacings       observed     expected
        0           4.       67.668
        1          12.      135.335
        2          36.      135.335
        3          63.       90.224
        4          98.       45.112
        5          83.       18.045
  6 to INF        204.        8.282
 Chisquare with  6 d.o.f. =  5174.52 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           net_out.rbnf    using bits  2 to 25   2.548
  duplicate       number       number 
  spacings       observed     expected
        0          34.       67.668
        1          87.      135.335
        2         155.      135.335
        3         103.       90.224
        4          72.       45.112
        5          27.       18.045
  6 to INF         22.        8.282
 Chisquare with  6 d.o.f. =    81.87 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           net_out.rbnf    using bits  3 to 26   2.570
  duplicate       number       number 
  spacings       observed     expected
        0          38.       67.668
        1          86.      135.335
        2         149.      135.335
        3          99.       90.224
        4          68.       45.112
        5          35.       18.045
  6 to INF         25.        8.282
 Chisquare with  6 d.o.f. =    94.52 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           net_out.rbnf    using bits  4 to 27   2.742
  duplicate       number       number 
  spacings       observed     expected
        0          37.       67.668
        1          90.      135.335
        2          99.      135.335
        3         135.       90.224
        4          70.       45.112
        5          36.       18.045
  6 to INF         33.        8.282
 Chisquare with  6 d.o.f. =   166.43 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           net_out.rbnf    using bits  5 to 28   2.600
  duplicate       number       number 
  spacings       observed     expected
        0          37.       67.668
        1         101.      135.335
        2         110.      135.335
        3         125.       90.224
        4          70.       45.112
        5          28.       18.045
  6 to INF         29.        8.282
 Chisquare with  6 d.o.f. =   111.81 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           net_out.rbnf    using bits  6 to 29   2.640
  duplicate       number       number 
  spacings       observed     expected
        0          32.       67.668
        1         100.      135.335
        2         112.      135.335
        3         123.       90.224
        4          72.       45.112
        5          41.       18.045
  6 to INF         20.        8.282
 Chisquare with  6 d.o.f. =   105.77 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           net_out.rbnf    using bits  7 to 30   2.540
  duplicate       number       number 
  spacings       observed     expected
        0          42.       67.668
        1          98.      135.335
        2         124.      135.335
        3         106.       90.224
        4          75.       45.112
        5          34.       18.045
  6 to INF         21.        8.282
 Chisquare with  6 d.o.f. =    77.19 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           net_out.rbnf    using bits  8 to 31   2.788
  duplicate       number       number 
  spacings       observed     expected
        0          30.       67.668
        1          87.      135.335
        2         116.      135.335
        3         114.       90.224
        4          74.       45.112
        5          55.       18.045
  6 to INF         24.        8.282
 Chisquare with  6 d.o.f. =   171.27 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           net_out.rbnf    using bits  9 to 32   3.028
  duplicate       number       number 
  spacings       observed     expected
        0          35.       67.668
        1          66.      135.335
        2         102.      135.335
        3         106.       90.224
        4         100.       45.112
        5          46.       18.045
  6 to INF         45.        8.282
 Chisquare with  6 d.o.f. =   335.15 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
   The 9 p-values were
       1.000000  1.000000  1.000000  1.000000  1.000000
       1.000000  1.000000  1.000000  1.000000
  A KSTEST for the 9 p-values yields 1.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 net_out.rbnf   
     For a sample of 1,000,000 consecutive 5-tuples,
 chisquare for 99 degrees of freedom=143.711; p-value= .997739
           OPERM5 test for file net_out.rbnf   
     For a sample of 1,000,000 consecutive 5-tuples,
 chisquare for 99 degrees of freedom=107.195; p-value= .730519
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     :: This is the BINARY RANK TEST for 31x31 matrices. The leftmost ::        
     :: 31 bits of 31 random integers from the test sequence are used ::        
     :: to form a 31x31 binary matrix over the field {0,1}. The rank  ::        
     :: is determined. That rank can be from 0 to 31, but ranks< 28   ::        
     :: are rare, and their counts are pooled with those for rank 28. ::        
     :: Ranks are found for 40,000 such random matrices and a chisqua-::        
     :: re test is performed on counts for ranks 31,30,29 and <=28.   ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
    Binary rank test for net_out.rbnf   
         Rank test for 31x31 binary matrices:
        rows from leftmost 31 bits of each 32-bit integer
      rank   observed  expected (o-e)^2/e  sum
        28      9369     211.4*******************
        29     30631    5134.0*******************
        30         0   23103.0*******************
        31         0   11551.5*******************
  chisquare=****** for 3 d. of f.; p-value=1.000000
--------------------------------------------------------------
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     :: This is the BINARY RANK TEST for 32x32 matrices. A random 32x ::        
     :: 32 binary matrix is formed, each row a 32-bit random integer. ::        
     :: The rank is determined. That rank can be from 0 to 32, ranks  ::        
     :: less than 29 are rare, and their counts are pooled with those ::        
     :: for rank 29.  Ranks are found for 40,000 such random matrices ::        
     :: and a chisquare test is performed on counts for ranks  32,31, ::        
     :: 30 and <=29.                                                  ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
    Binary rank test for net_out.rbnf   
         Rank test for 32x32 binary matrices:
        rows from leftmost 32 bits of each 32-bit integer
      rank   observed  expected (o-e)^2/e  sum
        29      9169     211.4*******************
        30     30831    5134.0*******************
        31         0   23103.0*******************
        32         0   11551.5*******************
  chisquare=****** for 3 d. of f.; p-value=1.000000
--------------------------------------------------------------

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     :: This is the BINARY RANK TEST for 6x8 matrices.  From each of  ::        
     :: six random 32-bit integers from the generator under test, a   ::        
     :: specified byte is chosen, and the resulting six bytes form a  ::        
     :: 6x8 binary matrix whose rank is determined.  That rank can be ::        
     :: from 0 to 6, but ranks 0,1,2,3 are rare; their counts are     ::        
     :: pooled with those for rank 4. Ranks are found for 100,000     ::        
     :: random matrices, and a chi-square test is performed on        ::        
     :: counts for ranks 6,5 and <=4.                                 ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
         Binary Rank Test for net_out.rbnf   
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits  1 to  8
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         3542       944.3    7146.065    7146.065
          r =5        37959     21743.9   12092.100   19238.170
          r =6        58499     77311.8    4577.847   23816.020
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits  2 to  9
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          916       944.3        .848        .848
          r =5        21679     21743.9        .194       1.042
          r =6        77405     77311.8        .112       1.154
                        p=1-exp(-SUM/2)= .43849
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits  3 to 10
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          927       944.3        .317        .317
          r =5        21719     21743.9        .029        .346
          r =6        77354     77311.8        .023        .369
                        p=1-exp(-SUM/2)= .16829
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits  4 to 11
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          922       944.3        .527        .527
          r =5        21871     21743.9        .743       1.270
          r =6        77207     77311.8        .142       1.412
                        p=1-exp(-SUM/2)= .50631
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits  5 to 12
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          920       944.3        .625        .625
          r =5        21712     21743.9        .047        .672
          r =6        77368     77311.8        .041        .713
                        p=1-exp(-SUM/2)= .29989
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits  6 to 13
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          978       944.3       1.203       1.203
          r =5        21726     21743.9        .015       1.217
          r =6        77296     77311.8        .003       1.221
                        p=1-exp(-SUM/2)= .45680
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits  7 to 14
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          916       944.3        .848        .848
          r =5        22000     21743.9       3.016       3.865
          r =6        77084     77311.8        .671       4.536
                        p=1-exp(-SUM/2)= .89647
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits  8 to 15
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          916       944.3        .848        .848
          r =5        21497     21743.9       2.804       3.652
          r =6        77587     77311.8        .980       4.631
                        p=1-exp(-SUM/2)= .90130
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits  9 to 16
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          940       944.3        .020        .020
          r =5        21664     21743.9        .294        .313
          r =6        77396     77311.8        .092        .405
                        p=1-exp(-SUM/2)= .18327
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 10 to 17
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         3583       944.3    7373.421    7373.421
          r =5        38417     21743.9   12784.840   20158.260
          r =6        58000     77311.8    4823.918   24982.180
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 11 to 18
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         3576       944.3    7334.353    7334.353
          r =5        38318     21743.9   12633.460   19967.820
          r =6        58106     77311.8    4771.107   24738.920
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 12 to 19
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         3526       944.3    7058.307    7058.307
          r =5        38414     21743.9   12780.240   19838.540
          r =6        58060     77311.8    4793.990   24632.540
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 13 to 20
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         3639       944.3    7689.708    7689.708
          r =5        38527     21743.9   12954.090   20643.800
          r =6        57834     77311.8    4907.205   25551.000
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 14 to 21
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         3553       944.3    7206.714    7206.714
          r =5        38410     21743.9   12774.110   19980.820
          r =6        58037     77311.8    4805.451   24786.270
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 15 to 22
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         3563       944.3    7262.071    7262.071
          r =5        38131     21743.9   12349.990   19612.060
          r =6        58306     77311.8    4672.257   24284.320
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 16 to 23
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         3651       944.3    7758.348    7758.348
          r =5        37995     21743.9   12145.850   19904.200
          r =6        58354     77311.8    4648.687   24552.890
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 17 to 24
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         3675       944.3    7896.543    7896.543
          r =5        37866     21743.9   11953.790   19850.340
          r =6        58459     77311.8    4597.335   24447.670
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 18 to 25
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          907       944.3       1.473       1.473
          r =5        21766     21743.9        .022       1.496
          r =6        77327     77311.8        .003       1.499
                        p=1-exp(-SUM/2)= .52737
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 19 to 26
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          921       944.3        .575        .575
          r =5        21711     21743.9        .050        .625
          r =6        77368     77311.8        .041        .666
                        p=1-exp(-SUM/2)= .28309
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 20 to 27
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          960       944.3        .261        .261
          r =5        21914     21743.9       1.331       1.592
          r =6        77126     77311.8        .447       2.038
                        p=1-exp(-SUM/2)= .63908
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 21 to 28
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          952       944.3        .063        .063
          r =5        21729     21743.9        .010        .073
          r =6        77319     77311.8        .001        .074
                        p=1-exp(-SUM/2)= .03615
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 22 to 29
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          963       944.3        .370        .370
          r =5        21961     21743.9       2.168       2.538
          r =6        77076     77311.8        .719       3.257
                        p=1-exp(-SUM/2)= .80379
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 23 to 30
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          921       944.3        .575        .575
          r =5        21780     21743.9        .060        .635
          r =6        77299     77311.8        .002        .637
                        p=1-exp(-SUM/2)= .27277
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 24 to 31
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          904       944.3       1.720       1.720
          r =5        21686     21743.9        .154       1.874
          r =6        77410     77311.8        .125       1.999
                        p=1-exp(-SUM/2)= .63192
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG net_out.rbnf   
     b-rank test for bits 25 to 32
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          956       944.3        .145        .145
          r =5        21684     21743.9        .165        .310
          r =6        77360     77311.8        .030        .340
                        p=1-exp(-SUM/2)= .15633
   TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices
 These should be 25 uniform [0,1] random variables:
    1.000000     .438492     .168286     .506309     .299889
     .456800     .896470     .901299     .183267    1.000000
    1.000000    1.000000    1.000000    1.000000    1.000000
    1.000000    1.000000     .527374     .283087     .639080
     .036154     .803785     .272771     .631917     .156332
   brank test summary for net_out.rbnf   
       The KS test for those 25 supposed UNI's yields
                    KS p-value=1.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, 20 BITS PER WORD, N words
   This test uses N=2^21 and samples the bitstream 20 times.
  No. missing words should average  141909. with sigma=428.
---------------------------------------------------------
 tst no  1:  169573 missing words,   64.63 sigmas from mean, p-value=1.00000
 tst no  2:  169451 missing words,   64.35 sigmas from mean, p-value=1.00000
 tst no  3:  169912 missing words,   65.43 sigmas from mean, p-value=1.00000
 tst no  4:  169295 missing words,   63.99 sigmas from mean, p-value=1.00000
 tst no  5:  169775 missing words,   65.11 sigmas from mean, p-value=1.00000
 tst no  6:  170435 missing words,   66.65 sigmas from mean, p-value=1.00000
 tst no  7:  168946 missing words,   63.17 sigmas from mean, p-value=1.00000
 tst no  8:  170116 missing words,   65.90 sigmas from mean, p-value=1.00000
 tst no  9:  169784 missing words,   65.13 sigmas from mean, p-value=1.00000
 tst no 10:  169100 missing words,   63.53 sigmas from mean, p-value=1.00000
 tst no 11:  169270 missing words,   63.93 sigmas from mean, p-value=1.00000
 tst no 12:  169535 missing words,   64.55 sigmas from mean, p-value=1.00000
 tst no 13:  170433 missing words,   66.64 sigmas from mean, p-value=1.00000
 tst no 14:  170230 missing words,   66.17 sigmas from mean, p-value=1.00000
 tst no 15:  168796 missing words,   62.82 sigmas from mean, p-value=1.00000
 tst no 16:  169419 missing words,   64.27 sigmas from mean, p-value=1.00000
 tst no 17:  169751 missing words,   65.05 sigmas from mean, p-value=1.00000
 tst no 18:  169532 missing words,   64.54 sigmas from mean, p-value=1.00000
 tst no 19:  168830 missing words,   62.90 sigmas from mean, p-value=1.00000
 tst no 20:  169772 missing words,   65.10 sigmas from mean, p-value=1.00000

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::             The tests OPSO, OQSO and DNA                      ::        
     ::         OPSO means Overlapping-Pairs-Sparse-Occupancy         ::        
     :: The OPSO test considers 2-letter words from an alphabet of    ::        
     :: 1024 letters.  Each letter is determined by a specified ten   ::        
     :: bits from a 32-bit integer in the sequence to be tested. OPSO ::        
     :: generates  2^21 (overlapping) 2-letter words  (from 2^21+1    ::        
     :: "keystrokes")  and counts the number of missing words---that  ::        
     :: is 2-letter words which do not appear in the entire sequence. ::        
     :: That count should be very close to normally distributed with  ::        
     :: mean 141,909, sigma 290. Thus (missingwrds-141909)/290 should ::        
     :: be a standard normal variable. The OPSO test takes 32 bits at ::        
     :: a time from the test file and uses a designated set of ten    ::        
     :: consecutive bits. It then restarts the file for the next de-  ::        
     :: signated 10 bits, and so on.                                  ::        
     ::                                                               ::        
     ::     OQSO means Overlapping-Quadruples-Sparse-Occupancy        ::        
     ::   The test OQSO is similar, except that it considers 4-letter ::        
     :: words from an alphabet of 32 letters, each letter determined  ::        
     :: by a designated string of 5 consecutive bits from the test    ::        
     :: file, elements of which are assumed 32-bit random integers.   ::        
     :: The mean number of missing words in a sequence of 2^21 four-  ::        
     :: letter words,  (2^21+3 "keystrokes"), is again 141909, with   ::        
     :: sigma = 295.  The mean is based on theory; sigma comes from   ::        
     :: extensive simulation.                                         ::        
     ::                                                               ::        
     ::    The DNA test considers an alphabet of 4 letters::  C,G,A,T,::        
     :: determined by two designated bits in the sequence of random   ::        
     :: integers being tested.  It considers 10-letter words, so that ::        
     :: as in OPSO and OQSO, there are 2^20 possible words, and the   ::        
     :: mean number of missing words from a string of 2^21  (over-    ::        
     :: lapping)  10-letter  words (2^21+9 "keystrokes") is 141909.   ::        
     :: The standard deviation sigma=339 was determined as for OQSO   ::        
     :: by simulation.  (Sigma for OPSO, 290, is the true value (to   ::        
     :: three places), not determined by simulation.                  ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
 OPSO test for generator net_out.rbnf   
  Output: No. missing words (mw), equiv normal variate (z), p-value (p)
                                                           mw     z     p
    OPSO for net_out.rbnf    using bits 23 to 32        142349  1.516  .9353
    OPSO for net_out.rbnf    using bits 22 to 31        142016   .368  .6435
    OPSO for net_out.rbnf    using bits 21 to 30        141868  -.143  .4433
    OPSO for net_out.rbnf    using bits 20 to 29        141893  -.056  .4775
    OPSO for net_out.rbnf    using bits 19 to 28        142364  1.568  .9415
    OPSO for net_out.rbnf    using bits 18 to 27        141751  -.546  .2925
    OPSO for net_out.rbnf    using bits 17 to 26        786515******* 1.0000
    OPSO for net_out.rbnf    using bits 16 to 25        786511******* 1.0000
    OPSO for net_out.rbnf    using bits 15 to 24        786504******* 1.0000
    OPSO for net_out.rbnf    using bits 14 to 23        786503******* 1.0000
    OPSO for net_out.rbnf    using bits 13 to 22        786514******* 1.0000
    OPSO for net_out.rbnf    using bits 12 to 21        786527******* 1.0000
    OPSO for net_out.rbnf    using bits 11 to 20        786518******* 1.0000
    OPSO for net_out.rbnf    using bits 10 to 19        786511******* 1.0000
    OPSO for net_out.rbnf    using bits  9 to 18        786524******* 1.0000
    OPSO for net_out.rbnf    using bits  8 to 17        786517******* 1.0000
    OPSO for net_out.rbnf    using bits  7 to 16        141683  -.780  .2176
    OPSO for net_out.rbnf    using bits  6 to 15        142121   .730  .7673
    OPSO for net_out.rbnf    using bits  5 to 14        142451  1.868  .9691
    OPSO for net_out.rbnf    using bits  4 to 13        141813  -.332  .3699
    OPSO for net_out.rbnf    using bits  3 to 12        142192   .975  .8352
    OPSO for net_out.rbnf    using bits  2 to 11        141768  -.487  .3130
    OPSO for net_out.rbnf    using bits  1 to 10        786525******* 1.0000
 OQSO test for generator net_out.rbnf   
  Output: No. missing words (mw), equiv normal variate (z), p-value (p)
                                                           mw     z     p
    OQSO for net_out.rbnf    using bits 28 to 32        141761  -.503  .3075
    OQSO for net_out.rbnf    using bits 27 to 31        141736  -.588  .2784
    OQSO for net_out.rbnf    using bits 26 to 30        141866  -.147  .4416
    OQSO for net_out.rbnf    using bits 25 to 29        142024   .389  .6513
    OQSO for net_out.rbnf    using bits 24 to 28        142091   .616  .7310
    OQSO for net_out.rbnf    using bits 23 to 27        142143   .792  .7859
    OQSO for net_out.rbnf    using bits 22 to 26        141707  -.686  .2464
    OQSO for net_out.rbnf    using bits 21 to 25        142085   .595  .7242
    OQSO for net_out.rbnf    using bits 20 to 24        141259 -2.205  .0137
    OQSO for net_out.rbnf    using bits 19 to 23        141907  -.008  .4969
    OQSO for net_out.rbnf    using bits 18 to 22        142032   .416  .6612
    OQSO for net_out.rbnf    using bits 17 to 21        983040******* 1.0000
    OQSO for net_out.rbnf    using bits 16 to 20        983040******* 1.0000
    OQSO for net_out.rbnf    using bits 15 to 19        983040******* 1.0000
    OQSO for net_out.rbnf    using bits 14 to 18        983040******* 1.0000
    OQSO for net_out.rbnf    using bits 13 to 17        983040******* 1.0000
    OQSO for net_out.rbnf    using bits 12 to 16        142272  1.229  .8905
    OQSO for net_out.rbnf    using bits 11 to 15        141695  -.727  .2338
    OQSO for net_out.rbnf    using bits 10 to 14        141582 -1.110  .1336
    OQSO for net_out.rbnf    using bits  9 to 13        141567 -1.160  .1229
    OQSO for net_out.rbnf    using bits  8 to 12        142117   .704  .7593
    OQSO for net_out.rbnf    using bits  7 to 11        142030   .409  .6588
    OQSO for net_out.rbnf    using bits  6 to 10        141754  -.527  .2993
    OQSO for net_out.rbnf    using bits  5 to  9        142027   .399  .6550
    OQSO for net_out.rbnf    using bits  4 to  8        141863  -.157  .4376
    OQSO for net_out.rbnf    using bits  3 to  7        141750  -.540  .2946
    OQSO for net_out.rbnf    using bits  2 to  6        141959   .168  .5669
    OQSO for net_out.rbnf    using bits  1 to  5        983040******* 1.0000
  DNA test for generator net_out.rbnf   
  Output: No. missing words (mw), equiv normal variate (z), p-value (p)
                                                           mw     z     p
     DNA for net_out.rbnf    using bits 31 to 32        141962   .155  .5617
     DNA for net_out.rbnf    using bits 30 to 31        141435 -1.399  .0809
     DNA for net_out.rbnf    using bits 29 to 30        142229   .943  .8272
     DNA for net_out.rbnf    using bits 28 to 29        141108 -2.364  .0090
     DNA for net_out.rbnf    using bits 27 to 28        141704  -.606  .2724
     DNA for net_out.rbnf    using bits 26 to 27        141578  -.977  .1642
     DNA for net_out.rbnf    using bits 25 to 26        142114   .604  .7270
     DNA for net_out.rbnf    using bits 24 to 25        141327 -1.718  .0429
     DNA for net_out.rbnf    using bits 23 to 24        141896  -.039  .4843
     DNA for net_out.rbnf    using bits 22 to 23        141885  -.072  .4714
     DNA for net_out.rbnf    using bits 21 to 22        142166   .757  .7755
     DNA for net_out.rbnf    using bits 20 to 21        142333  1.250  .8943
     DNA for net_out.rbnf    using bits 19 to 20        141897  -.036  .4855
     DNA for net_out.rbnf    using bits 18 to 19        141705  -.603  .2733
     DNA for net_out.rbnf    using bits 17 to 18       1047552******* 1.0000
     DNA for net_out.rbnf    using bits 16 to 17       1047552******* 1.0000
     DNA for net_out.rbnf    using bits 15 to 16        142103   .571  .7161
     DNA for net_out.rbnf    using bits 14 to 15        141882  -.081  .4679
     DNA for net_out.rbnf    using bits 13 to 14        142237   .967  .8331
     DNA for net_out.rbnf    using bits 12 to 13        141532 -1.113  .1328
     DNA for net_out.rbnf    using bits 11 to 12        142020   .326  .6280
     DNA for net_out.rbnf    using bits 10 to 11        141657  -.744  .2283
     DNA for net_out.rbnf    using bits  9 to 10        141828  -.240  .4052
     DNA for net_out.rbnf    using bits  8 to  9        142480  1.683  .9539
     DNA for net_out.rbnf    using bits  7 to  8        141927   .052  .5208
     DNA for net_out.rbnf    using bits  6 to  7        141893  -.048  .4808
     DNA for net_out.rbnf    using bits  5 to  6        141460 -1.325  .0925
     DNA for net_out.rbnf    using bits  4 to  5        141657  -.744  .2283
     DNA for net_out.rbnf    using bits  3 to  4        142061   .447  .6727
     DNA for net_out.rbnf    using bits  2 to  3        141776  -.393  .3470
     DNA for net_out.rbnf    using bits  1 to  2       1047552******* 1.0000

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::     This is the COUNT-THE-1's TEST on a stream of bytes.      ::        
     :: Consider the file under test as a stream of bytes (four per   ::        
     :: 32 bit integer).  Each byte can contain from 0 to 8 1's,      ::        
     :: with probabilities 1,8,28,56,70,56,28,8,1 over 256.  Now let  ::        
     :: the stream of bytes provide a string of overlapping  5-letter ::        
     :: words, each "letter" taking values A,B,C,D,E. The letters are ::        
     :: determined by the number of 1's in a byte::  0,1,or 2 yield A,::        
     :: 3 yields B, 4 yields C, 5 yields D and 6,7 or 8 yield E. Thus ::        
     :: we have a monkey at a typewriter hitting five keys with vari- ::        
     :: ous probabilities (37,56,70,56,37 over 256).  There are 5^5   ::        
     :: possible 5-letter words, and from a string of 256,000 (over-  ::        
     :: lapping) 5-letter words, counts are made on the frequencies   ::        
     :: for each word.   The quadratic form in the weak inverse of    ::        
     :: the covariance matrix of the cell counts provides a chisquare ::        
     :: test::  Q5-Q4, the difference of the naive Pearson sums of    ::        
     :: (OBS-EXP)^2/EXP on counts for 5- and 4-letter cell counts.    ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
   Test results for net_out.rbnf   
 Chi-square with 5^5-5^4=2500 d.of f. for sample size:2560000
                               chisquare  equiv normal  p-value
  Results fo COUNT-THE-1's in successive bytes:
 byte stream for net_out.rbnf    99146.78   1366.792     1.000000
 byte stream for net_out.rbnf   100118.30   1380.531     1.000000

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::     This is the COUNT-THE-1's TEST for specific bytes.        ::        
     :: Consider the file under test as a stream of 32-bit integers.  ::        
     :: From each integer, a specific byte is chosen , say the left-  ::        
     :: most::  bits 1 to 8. Each byte can contain from 0 to 8 1's,   ::        
     :: with probabilitie 1,8,28,56,70,56,28,8,1 over 256.  Now let   ::        
     :: the specified bytes from successive integers provide a string ::        
     :: of (overlapping) 5-letter words, each "letter" taking values  ::        
     :: A,B,C,D,E. The letters are determined  by the number of 1's,  ::        
     :: in that byte::  0,1,or 2 ---> A, 3 ---> B, 4 ---> C, 5 ---> D,::        
     :: and  6,7 or 8 ---> E.  Thus we have a monkey at a typewriter  ::        
     :: hitting five keys with with various probabilities::  37,56,70,::        
     :: 56,37 over 256. There are 5^5 possible 5-letter words, and    ::        
     :: from a string of 256,000 (overlapping) 5-letter words, counts ::        
     :: are made on the frequencies for each word. The quadratic form ::        
     :: in the weak inverse of the covariance matrix of the cell      ::        
     :: counts provides a chisquare test::  Q5-Q4, the difference of  ::        
     :: the naive Pearson  sums of (OBS-EXP)^2/EXP on counts for 5-   ::        
     :: and 4-letter cell counts.                                     ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
 Chi-square with 5^5-5^4=2500 d.of f. for sample size: 256000
                      chisquare  equiv normal  p value
  Results for COUNT-THE-1's in specified bytes:
           bits  1 to  8 50405.77    677.490     1.000000
           bits  2 to  9  2552.36       .740      .770498
           bits  3 to 10  2601.35      1.433      .924113
           bits  4 to 11  2552.19       .738      .769753
           bits  5 to 12  2537.58       .531      .702440
           bits  6 to 13  2502.22       .031      .512521
           bits  7 to 14  2391.28     -1.538      .062074
           bits  8 to 15  2491.19      -.125      .450430
           bits  9 to 16  2512.03       .170      .567536
           bits 10 to 17 51356.86    690.940     1.000000
           bits 11 to 18 51619.03    694.648     1.000000
           bits 12 to 19 50927.70    684.871     1.000000
           bits 13 to 20 51476.92    692.638     1.000000
           bits 14 to 21 51668.66    695.350     1.000000
           bits 15 to 22 51569.03    693.941     1.000000
           bits 16 to 23 50675.28    681.301     1.000000
           bits 17 to 24 51223.92    689.060     1.000000
           bits 18 to 25  2480.85      -.271      .393260
           bits 19 to 26  2503.63       .051      .520446
           bits 20 to 27  2514.93       .211      .583635
           bits 21 to 28  2498.62      -.020      .492213
           bits 22 to 29  2583.72      1.184      .881778
           bits 23 to 30  2373.18     -1.794      .036445
           bits 24 to 31  2749.17      3.524      .999787
           bits 25 to 32  2550.96       .721      .764437

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::               THIS IS A PARKING LOT TEST                      ::        
     :: In a square of side 100, randomly "park" a car---a circle of  ::        
     :: radius 1.   Then try to park a 2nd, a 3rd, and so on, each    ::        
     :: time parking "by ear".  That is, if an attempt to park a car  ::        
     :: causes a crash with one already parked, try again at a new    ::        
     :: random location. (To avoid path problems, consider parking    ::        
     :: helicopters rather than cars.)   Each attempt leads to either ::        
     :: a crash or a success, the latter followed by an increment to  ::        
     :: the list of cars already parked. If we plot n:  the number of ::        
     :: attempts, versus k::  the number successfully parked, we get a::        
     :: curve that should be similar to those provided by a perfect   ::        
     :: random number generator.  Theory for the behavior of such a   ::        
     :: random curve seems beyond reach, and as graphics displays are ::        
     :: not available for this battery of tests, a simple characteriz ::        
     :: ation of the random experiment is used: k, the number of cars ::        
     :: successfully parked after n=12,000 attempts. Simulation shows ::        
     :: that k should average 3523 with sigma 21.9 and is very close  ::        
     :: to normally distributed.  Thus (k-3523)/21.9 should be a st-  ::        
     :: andard normal variable, which, converted to a uniform varia-  ::        
     :: ble, provides input to a KSTEST based on a sample of 10.      ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
           CDPARK: result of ten tests on file net_out.rbnf   
            Of 12,000 tries, the average no. of successes
                 should be 3523 with sigma=21.9
            Successes: 1173    z-score:******* p-value: .000000
            Successes: 1175    z-score:******* p-value: .000000
            Successes: 1176    z-score:******* p-value: .000000
            Successes: 1193    z-score:******* p-value: .000000
            Successes: 1170    z-score:******* p-value: .000000
            Successes: 1183    z-score:******* p-value: .000000
            Successes: 1168    z-score:******* p-value: .000000
            Successes: 1179    z-score:******* p-value: .000000
            Successes: 1188    z-score:******* p-value: .000000
            Successes: 1177    z-score:******* p-value: .000000
 
           square size   avg. no.  parked   sample sigma
             100.            1178.200        7.440
            KSTEST for the above 10: p= 1.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 random integers in the file net_out.rbnf   
     Sample no.    d^2     avg     equiv uni            
           5     .2258    .1921     .203040
          10     .6656    .2594     .487744
          15     .4633    .2489     .372287
          20     .0424    .2266     .041749
          25     .2217    .2325     .199727
          30     .0218    .2448     .021711
          35     .0516    .2395     .050492
          40     .0798    .2489     .077066
          45     .0629    .2331     .061242
          50     .2636    .2418     .232726
          55     .0162    .2333     .016121
          60     .2499    .2399     .222073
          65     .0768    .2305     .074252
          70     .0000    .2198     .000001
          75     .8635    .2422     .580162
          80     .0902    .2379     .086628
          85     .4389    .2418     .356683
          90     .7755    .2504     .541302
          95     .5807    .2512     .442114
         100     .0246    .2486     .024457
     MINIMUM DISTANCE TEST for net_out.rbnf   
          Result of KS test on 20 transformed mindist^2's:
                                  p-value=1.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 net_out.rbnf   
 sample no:  1     r^3=   1.004     p-value= .03291
 sample no:  2     r^3=   1.228     p-value= .04010
 sample no:  3     r^3=   7.467     p-value= .22033
 sample no:  4     r^3=   5.840     p-value= .17688
 sample no:  5     r^3=    .698     p-value= .02299
 sample no:  6     r^3=   1.947     p-value= .06285
 sample no:  7     r^3=   5.116     p-value= .15680
 sample no:  8     r^3=  11.201     p-value= .31158
 sample no:  9     r^3=    .130     p-value= .00433
 sample no: 10     r^3=   8.450     p-value= .24547
 sample no: 11     r^3=    .772     p-value= .02542
 sample no: 12     r^3=    .814     p-value= .02678
 sample no: 13     r^3=   5.034     p-value= .15448
 sample no: 14     r^3=   2.730     p-value= .08698
 sample no: 15     r^3=    .497     p-value= .01642
 sample no: 16     r^3=   2.151     p-value= .06918
 sample no: 17     r^3=   2.345     p-value= .07520
 sample no: 18     r^3=   2.304     p-value= .07391
 sample no: 19     r^3=  14.069     p-value= .37435
 sample no: 20     r^3=    .918     p-value= .03015
  A KS test is applied to those 20 p-values.
---------------------------------------------------------
       3DSPHERES test for file net_out.rbnf         p-value=1.000000
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::      This is the SQEEZE test                                  ::        
     ::  Random integers are floated to get uniforms on [0,1). Start- ::        
     ::  ing with k=2^31=2147483647, the test finds j, the number of  ::        
     ::  iterations necessary to reduce k to 1, using the reduction   ::        
     ::  k=ceiling(k*U), with U provided by floating integers from    ::        
     ::  the file being tested.  Such j's are found 100,000 times,    ::        
     ::  then counts for the number of times j was <=6,7,...,47,>=48  ::        
     ::  are used to provide a chi-square test for cell frequencies.  ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'hycrotan 'nonBinary))
Image

User avatar
Wolfy
Fleet Admiral
Fleet Admiral
Posts: 5351
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

Sun Oct 13, 2013 12:51 am

Now, if you want to see something especially abysmal, these are the results from randu! (again for seed 123412341234)
http://en.wikipedia.org/wiki/RANDU

Code: Select all

       NOTE: Most of the tests in DIEHARD return a p-value, which               
       should be uniform on [0,1) if the input file contains truly              
       independent random bits.   Those p-values are obtained by                
       p=F(X), where F is the assumed distribution of the sample                
       random variable X---often normal. But that assumed F is just             
       an asymptotic approximation, for which the fit will be worst             
       in the tails. Thus you should not be surprised with                      
       occasional p-values near 0 or 1, such as .0012 or .9983.                 
       When a bit stream really FAILS BIG, you will get p's of 0 or             
       1 to six or more places.  By all means, do not, as a                     
       Statistician might, think that a p < .025 or p> .975 means               
       that the RNG has "failed the test at the .05 level".  Such               
       p's happen among the hundreds that DIEHARD produces, even                
       with good RNG's.  So keep in mind that " p happens".                     
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::            This is the BIRTHDAY SPACINGS TEST                 ::        
     :: Choose m birthdays in a year of n days.  List the spacings    ::        
     :: between the birthdays.  If j is the number of values that     ::        
     :: occur more than once in that list, then j is asymptotically   ::        
     :: Poisson distributed with mean m^3/(4n).  Experience shows n   ::        
     :: must be quite large, say n>=2^18, for comparing the results   ::        
     :: to the Poisson distribution with that mean.  This test uses   ::        
     :: n=2^24 and m=2^9,  so that the underlying distribution for j  ::        
     :: is taken to be Poisson with lambda=2^27/(2^26)=2.  A sample   ::        
     :: of 500 j's is taken, and a chi-square goodness of fit test    ::        
     :: provides a p value.  The first test uses bits 1-24 (counting  ::        
     :: from the left) from integers in the specified file.           ::        
     ::   Then the file is closed and reopened. Next, bits 2-25 are   ::        
     :: used to provide birthdays, then 3-26 and so on to bits 9-32.  ::        
     :: Each set of bits provides a p-value, and the nine p-values    ::        
     :: provide a sample for a KSTEST.                                ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
 BIRTHDAY SPACINGS TEST, M= 512 N=2**24 LAMBDA=  2.0000
           Results for randu_out.rbnf 
                   For a sample of size 500:     mean   
           randu_out.rbnf  using bits  1 to 24 506.750
  duplicate       number       number 
  spacings       observed     expected
        0         500.       67.668
        1           0.      135.335
        2           0.      135.335
        3           0.       90.224
        4           0.       45.112
        5           0.       18.045
  6 to INF          0.        8.282
 Chisquare with  6 d.o.f. =  3194.53 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           randu_out.rbnf  using bits  2 to 25 503.878
  duplicate       number       number 
  spacings       observed     expected
        0         500.       67.668
        1           0.      135.335
        2           0.      135.335
        3           0.       90.224
        4           0.       45.112
        5           0.       18.045
  6 to INF          0.        8.282
 Chisquare with  6 d.o.f. =  3194.53 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           randu_out.rbnf  using bits  3 to 26 498.626
  duplicate       number       number 
  spacings       observed     expected
        0         500.       67.668
        1           0.      135.335
        2           0.      135.335
        3           0.       90.224
        4           0.       45.112
        5           0.       18.045
  6 to INF          0.        8.282
 Chisquare with  6 d.o.f. =  3194.53 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           randu_out.rbnf  using bits  4 to 27 489.878
  duplicate       number       number 
  spacings       observed     expected
        0         500.       67.668
        1           0.      135.335
        2           0.      135.335
        3           0.       90.224
        4           0.       45.112
        5           0.       18.045
  6 to INF          0.        8.282
 Chisquare with  6 d.o.f. =  3194.53 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           randu_out.rbnf  using bits  5 to 28 473.880
  duplicate       number       number 
  spacings       observed     expected
        0         500.       67.668
        1           0.      135.335
        2           0.      135.335
        3           0.       90.224
        4           0.       45.112
        5           0.       18.045
  6 to INF          0.        8.282
 Chisquare with  6 d.o.f. =  3194.53 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           randu_out.rbnf  using bits  6 to 29 473.880
  duplicate       number       number 
  spacings       observed     expected
        0         500.       67.668
        1           0.      135.335
        2           0.      135.335
        3           0.       90.224
        4           0.       45.112
        5           0.       18.045
  6 to INF          0.        8.282
 Chisquare with  6 d.o.f. =  3194.53 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           randu_out.rbnf  using bits  7 to 30 426.332
  duplicate       number       number 
  spacings       observed     expected
        0         500.       67.668
        1           0.      135.335
        2           0.      135.335
        3           0.       90.224
        4           0.       45.112
        5           0.       18.045
  6 to INF          0.        8.282
 Chisquare with  6 d.o.f. =  3194.53 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           randu_out.rbnf  using bits  8 to 31 425.394
  duplicate       number       number 
  spacings       observed     expected
        0         500.       67.668
        1           0.      135.335
        2           0.      135.335
        3           0.       90.224
        4           0.       45.112
        5           0.       18.045
  6 to INF          0.        8.282
 Chisquare with  6 d.o.f. =  3194.53 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
                   For a sample of size 500:     mean   
           randu_out.rbnf  using bits  9 to 32 425.394
  duplicate       number       number 
  spacings       observed     expected
        0         500.       67.668
        1           0.      135.335
        2           0.      135.335
        3           0.       90.224
        4           0.       45.112
        5           0.       18.045
  6 to INF          0.        8.282
 Chisquare with  6 d.o.f. =  3194.53 p-value= 1.000000
  :::::::::::::::::::::::::::::::::::::::::
   The 9 p-values were
       1.000000  1.000000  1.000000  1.000000  1.000000
       1.000000  1.000000  1.000000  1.000000
  A KSTEST for the 9 p-values yields 1.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 randu_out.rbnf 
     For a sample of 1,000,000 consecutive 5-tuples,
 chisquare for 99 degrees of freedom=*******; p-value=1.000000
           OPERM5 test for file randu_out.rbnf 
     For a sample of 1,000,000 consecutive 5-tuples,
 chisquare for 99 degrees of freedom=*******; p-value=1.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 chisqua-::        
     :: re test is performed on counts for ranks 31,30,29 and <=28.   ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
    Binary rank test for randu_out.rbnf 
         Rank test for 31x31 binary matrices:
        rows from leftmost 31 bits of each 32-bit integer
      rank   observed  expected (o-e)^2/e  sum
        28     40000     211.4*******************
        29         0    5134.0*******************
        30         0   23103.0*******************
        31         0   11551.5*******************
  chisquare=****** for 3 d. of f.; p-value=1.000000
--------------------------------------------------------------
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     :: This is the BINARY RANK TEST for 32x32 matrices. A random 32x ::        
     :: 32 binary matrix is formed, each row a 32-bit random integer. ::        
     :: The rank is determined. That rank can be from 0 to 32, ranks  ::        
     :: less than 29 are rare, and their counts are pooled with those ::        
     :: for rank 29.  Ranks are found for 40,000 such random matrices ::        
     :: and a chisquare test is performed on counts for ranks  32,31, ::        
     :: 30 and <=29.                                                  ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
    Binary rank test for randu_out.rbnf 
         Rank test for 32x32 binary matrices:
        rows from leftmost 32 bits of each 32-bit integer
      rank   observed  expected (o-e)^2/e  sum
        29     40000     211.4*******************
        30         0    5134.0*******************
        31         0   23103.0*******************
        32         0   11551.5*******************
  chisquare=****** for 3 d. of f.; p-value=1.000000
--------------------------------------------------------------

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     :: This is the BINARY RANK TEST for 6x8 matrices.  From each of  ::        
     :: six random 32-bit integers from the generator under test, a   ::        
     :: specified byte is chosen, and the resulting six bytes form a  ::        
     :: 6x8 binary matrix whose rank is determined.  That rank can be ::        
     :: from 0 to 6, but ranks 0,1,2,3 are rare; their counts are     ::        
     :: pooled with those for rank 4. Ranks are found for 100,000     ::        
     :: random matrices, and a chi-square test is performed on        ::        
     :: counts for ranks 6,5 and <=4.                                 ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
         Binary Rank Test for randu_out.rbnf 
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits  1 to  8
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4       100000       944.310390790.00010390790.000
          r =5            0     21743.9   21743.90010412530.000
          r =6            0     77311.8   77311.80010489840.000
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits  2 to  9
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4       100000       944.310390790.00010390790.000
          r =5            0     21743.9   21743.90010412530.000
          r =6            0     77311.8   77311.80010489840.000
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits  3 to 10
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4       100000       944.310390790.00010390790.000
          r =5            0     21743.9   21743.90010412530.000
          r =6            0     77311.8   77311.80010489840.000
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits  4 to 11
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4       100000       944.310390790.00010390790.000
          r =5            0     21743.9   21743.90010412530.000
          r =6            0     77311.8   77311.80010489840.000
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits  5 to 12
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4       100000       944.310390790.00010390790.000
          r =5            0     21743.9   21743.90010412530.000
          r =6            0     77311.8   77311.80010489840.000
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits  6 to 13
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4       100000       944.310390790.00010390790.000
          r =5            0     21743.9   21743.90010412530.000
          r =6            0     77311.8   77311.80010489840.000
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits  7 to 14
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4       100000       944.310390790.00010390790.000
          r =5            0     21743.9   21743.90010412530.000
          r =6            0     77311.8   77311.80010489840.000
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits  8 to 15
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4       100000       944.310390790.00010390790.000
          r =5            0     21743.9   21743.90010412530.000
          r =6            0     77311.8   77311.80010489840.000
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits  9 to 16
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4       100000       944.310390790.00010390790.000
          r =5            0     21743.9   21743.90010412530.000
          r =6            0     77311.8   77311.80010489840.000
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 10 to 17
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4       100000       944.310390790.00010390790.000
          r =5            0     21743.9   21743.90010412530.000
          r =6            0     77311.8   77311.80010489840.000
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 11 to 18
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4       100000       944.310390790.00010390790.000
          r =5            0     21743.9   21743.90010412530.000
          r =6            0     77311.8   77311.80010489840.000
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 12 to 19
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4       100000       944.310390790.00010390790.000
          r =5            0     21743.9   21743.90010412530.000
          r =6            0     77311.8   77311.80010489840.000
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 13 to 20
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4       100000       944.310390790.00010390790.000
          r =5            0     21743.9   21743.90010412530.000
          r =6            0     77311.8   77311.80010489840.000
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 14 to 21
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4        52545       944.3 2819685.000 2819685.000
          r =5        47455     21743.9   30402.120 2850087.000
          r =6            0     77311.8   77311.800 2927399.000
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 15 to 22
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4        20486       944.3  404402.700  404402.700
          r =5        56223     21743.9   54673.190  459075.900
          r =6        23291     77311.8   37746.460  496822.400
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 16 to 23
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         6421       944.3   31763.410   31763.410
          r =5        44090     21743.9   22964.980   54728.390
          r =6        49489     77311.8   10012.810   64741.200
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 17 to 24
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         2247       944.3    1797.121    1797.121
          r =5        25869     21743.9     782.585    2579.706
          r =6        71884     77311.8     381.068    2960.774
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 18 to 25
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         2489       944.3    2526.836    2526.836
          r =5        28278     21743.9    1963.514    4490.350
          r =6        69233     77311.8     844.206    5334.556
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 19 to 26
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         2147       944.3    1531.804    1531.804
          r =5        27937     21743.9    1763.919    3295.723
          r =6        69916     77311.8     707.498    4003.221
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 20 to 27
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         1562       944.3     404.057     404.057
          r =5        20314     21743.9      94.032     498.089
          r =6        78124     77311.8       8.532     506.621
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 21 to 28
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4          782       944.3      27.895      27.895
          r =5        19527     21743.9     226.024     253.920
          r =6        79691     77311.8      73.217     327.137
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 22 to 29
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         1563       944.3     405.367     405.367
          r =5        39059     21743.9   13788.360   14193.720
          r =6        59378     77311.8    4160.055   18353.780
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 23 to 30
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4         3126       944.3    5040.563    5040.563
          r =5        28126     21743.9    1873.224    6913.787
          r =6        68748     77311.8     948.610    7862.396
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 24 to 31
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4            0       944.3     944.301     944.301
          r =5        25000     21743.9     487.594    1431.895
          r =6        75000     77311.8      69.128    1501.023
                        p=1-exp(-SUM/2)=1.00000
        Rank of a 6x8 binary matrix,
     rows formed from eight bits of the RNG randu_out.rbnf 
     b-rank test for bits 25 to 32
                     OBSERVED   EXPECTED     (O-E)^2/E      SUM
          r<=4            0       944.3     944.301     944.301
          r =5        50000     21743.9   36718.670   37662.970
          r =6        50000     77311.8    9648.393   47311.370
                        p=1-exp(-SUM/2)=1.00000
   TEST SUMMARY, 25 tests on 100,000 random 6x8 matrices
 These should be 25 uniform [0,1] random variables:
    1.000000    1.000000    1.000000    1.000000    1.000000
    1.000000    1.000000    1.000000    1.000000    1.000000
    1.000000    1.000000    1.000000    1.000000    1.000000
    1.000000    1.000000    1.000000    1.000000    1.000000
    1.000000    1.000000    1.000000    1.000000    1.000000
   brank test summary for randu_out.rbnf 
       The KS test for those 25 supposed UNI's yields
                    KS p-value=1.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, 20 BITS PER WORD, N words
   This test uses N=2^21 and samples the bitstream 20 times.
  No. missing words should average  141909. with sigma=428.
---------------------------------------------------------
 tst no  1:  977524 missing words, 1952.37 sigmas from mean, p-value=1.00000
 tst no  2:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no  3:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no  4:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no  5:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no  6:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no  7:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no  8:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no  9:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no 10:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no 11:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no 12:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no 13:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no 14:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no 15:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no 16:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no 17:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no 18:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no 19:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000
 tst no 20:  977541 missing words, 1952.41 sigmas from mean, p-value=1.00000

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::             The tests OPSO, OQSO and DNA                      ::        
     ::         OPSO means Overlapping-Pairs-Sparse-Occupancy         ::        
     :: The OPSO test considers 2-letter words from an alphabet of    ::        
     :: 1024 letters.  Each letter is determined by a specified ten   ::        
     :: bits from a 32-bit integer in the sequence to be tested. OPSO ::        
     :: generates  2^21 (overlapping) 2-letter words  (from 2^21+1    ::        
     :: "keystrokes")  and counts the number of missing words---that  ::        
     :: is 2-letter words which do not appear in the entire sequence. ::        
     :: That count should be very close to normally distributed with  ::        
     :: mean 141,909, sigma 290. Thus (missingwrds-141909)/290 should ::        
     :: be a standard normal variable. The OPSO test takes 32 bits at ::        
     :: a time from the test file and uses a designated set of ten    ::        
     :: consecutive bits. It then restarts the file for the next de-  ::        
     :: signated 10 bits, and so on.                                  ::        
     ::                                                               ::        
     ::     OQSO means Overlapping-Quadruples-Sparse-Occupancy        ::        
     ::   The test OQSO is similar, except that it considers 4-letter ::        
     :: words from an alphabet of 32 letters, each letter determined  ::        
     :: by a designated string of 5 consecutive bits from the test    ::        
     :: file, elements of which are assumed 32-bit random integers.   ::        
     :: The mean number of missing words in a sequence of 2^21 four-  ::        
     :: letter words,  (2^21+3 "keystrokes"), is again 141909, with   ::        
     :: sigma = 295.  The mean is based on theory; sigma comes from   ::        
     :: extensive simulation.                                         ::        
     ::                                                               ::        
     ::    The DNA test considers an alphabet of 4 letters::  C,G,A,T,::        
     :: determined by two designated bits in the sequence of random   ::        
     :: integers being tested.  It considers 10-letter words, so that ::        
     :: as in OPSO and OQSO, there are 2^20 possible words, and the   ::        
     :: mean number of missing words from a string of 2^21  (over-    ::        
     :: lapping)  10-letter  words (2^21+9 "keystrokes") is 141909.   ::        
     :: The standard deviation sigma=339 was determined as for OQSO   ::        
     :: by simulation.  (Sigma for OPSO, 290, is the true value (to   ::        
     :: three places), not determined by simulation.                  ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
 OPSO test for generator randu_out.rbnf 
  Output: No. missing words (mw), equiv normal variate (z), p-value (p)
                                                           mw     z     p
    OPSO for randu_out.rbnf  using bits 23 to 32       1048448******* 1.0000
    OPSO for randu_out.rbnf  using bits 22 to 31       1048320******* 1.0000
    OPSO for randu_out.rbnf  using bits 21 to 30       1048064******* 1.0000
    OPSO for randu_out.rbnf  using bits 20 to 29       1047552******* 1.0000
    OPSO for randu_out.rbnf  using bits 19 to 28       1046528******* 1.0000
    OPSO for randu_out.rbnf  using bits 18 to 27       1045504******* 1.0000
    OPSO for randu_out.rbnf  using bits 17 to 26       1045504******* 1.0000
    OPSO for randu_out.rbnf  using bits 16 to 25       1047040******* 1.0000
    OPSO for randu_out.rbnf  using bits 15 to 24       1047808******* 1.0000
    OPSO for randu_out.rbnf  using bits 14 to 23       1048192******* 1.0000
    OPSO for randu_out.rbnf  using bits 13 to 22       1048384******* 1.0000
    OPSO for randu_out.rbnf  using bits 12 to 21       1048480******* 1.0000
    OPSO for randu_out.rbnf  using bits 11 to 20       1048528******* 1.0000
    OPSO for randu_out.rbnf  using bits 10 to 19       1048552******* 1.0000
    OPSO for randu_out.rbnf  using bits  9 to 18       1048564******* 1.0000
    OPSO for randu_out.rbnf  using bits  8 to 17       1048572******* 1.0000
    OPSO for randu_out.rbnf  using bits  7 to 16       1048572******* 1.0000
    OPSO for randu_out.rbnf  using bits  6 to 15       1048572******* 1.0000
    OPSO for randu_out.rbnf  using bits  5 to 14       1048572******* 1.0000
    OPSO for randu_out.rbnf  using bits  4 to 13       1048572******* 1.0000
    OPSO for randu_out.rbnf  using bits  3 to 12       1048572******* 1.0000
    OPSO for randu_out.rbnf  using bits  2 to 11       1048572******* 1.0000
    OPSO for randu_out.rbnf  using bits  1 to 10       1048572******* 1.0000
 OQSO test for generator randu_out.rbnf 
  Output: No. missing words (mw), equiv normal variate (z), p-value (p)
                                                           mw     z     p
    OQSO for randu_out.rbnf  using bits 28 to 32       1048572******* 1.0000
    OQSO for randu_out.rbnf  using bits 27 to 31       1048568******* 1.0000
    OQSO for randu_out.rbnf  using bits 26 to 30       1048560******* 1.0000
    OQSO for randu_out.rbnf  using bits 25 to 29       1048544******* 1.0000
    OQSO for randu_out.rbnf  using bits 24 to 28       1048512******* 1.0000
    OQSO for randu_out.rbnf  using bits 23 to 27       1048448******* 1.0000
    OQSO for randu_out.rbnf  using bits 22 to 26       1048320******* 1.0000
    OQSO for randu_out.rbnf  using bits 21 to 25       1048096******* 1.0000
    OQSO for randu_out.rbnf  using bits 20 to 24       1047840******* 1.0000
    OQSO for randu_out.rbnf  using bits 19 to 23       1047712******* 1.0000
    OQSO for randu_out.rbnf  using bits 18 to 22       1047712******* 1.0000
    OQSO for randu_out.rbnf  using bits 17 to 21       1047712******* 1.0000
    OQSO for randu_out.rbnf  using bits 16 to 20       1048144******* 1.0000
    OQSO for randu_out.rbnf  using bits 15 to 19       1048360******* 1.0000
    OQSO for randu_out.rbnf  using bits 14 to 18       1048468******* 1.0000
    OQSO for randu_out.rbnf  using bits 13 to 17       1048560******* 1.0000
    OQSO for randu_out.rbnf  using bits 12 to 16       1048560******* 1.0000
    OQSO for randu_out.rbnf  using bits 11 to 15       1048560******* 1.0000
    OQSO for randu_out.rbnf  using bits 10 to 14       1048560******* 1.0000
    OQSO for randu_out.rbnf  using bits  9 to 13       1048560******* 1.0000
    OQSO for randu_out.rbnf  using bits  8 to 12       1048560******* 1.0000
    OQSO for randu_out.rbnf  using bits  7 to 11       1048560******* 1.0000
    OQSO for randu_out.rbnf  using bits  6 to 10       1048560******* 1.0000
    OQSO for randu_out.rbnf  using bits  5 to  9       1048560******* 1.0000
    OQSO for randu_out.rbnf  using bits  4 to  8       1048560******* 1.0000
    OQSO for randu_out.rbnf  using bits  3 to  7       1048560******* 1.0000
    OQSO for randu_out.rbnf  using bits  2 to  6       1048560******* 1.0000
    OQSO for randu_out.rbnf  using bits  1 to  5       1048560******* 1.0000
  DNA test for generator randu_out.rbnf 
  Output: No. missing words (mw), equiv normal variate (z), p-value (p)
                                                           mw     z     p
     DNA for randu_out.rbnf  using bits 31 to 32       1048575******* 1.0000
     DNA for randu_out.rbnf  using bits 30 to 31       1048574******* 1.0000
     DNA for randu_out.rbnf  using bits 29 to 30       1048574******* 1.0000
     DNA for randu_out.rbnf  using bits 28 to 29       1048572******* 1.0000
     DNA for randu_out.rbnf  using bits 27 to 28       1048568******* 1.0000
     DNA for randu_out.rbnf  using bits 26 to 27       1048560******* 1.0000
     DNA for randu_out.rbnf  using bits 25 to 26       1048544******* 1.0000
     DNA for randu_out.rbnf  using bits 24 to 25       1048512******* 1.0000
     DNA for randu_out.rbnf  using bits 23 to 24       1048448******* 1.0000
     DNA for randu_out.rbnf  using bits 22 to 23       1048320******* 1.0000
     DNA for randu_out.rbnf  using bits 21 to 22       1048064******* 1.0000
     DNA for randu_out.rbnf  using bits 20 to 21       1047552******* 1.0000
     DNA for randu_out.rbnf  using bits 19 to 20       1046528******* 1.0000
     DNA for randu_out.rbnf  using bits 18 to 19       1044480******* 1.0000
     DNA for randu_out.rbnf  using bits 17 to 18       1040384******* 1.0000
     DNA for randu_out.rbnf  using bits 16 to 17       1047580******* 1.0000
     DNA for randu_out.rbnf  using bits 15 to 16       1047580******* 1.0000
     DNA for randu_out.rbnf  using bits 14 to 15       1047580******* 1.0000
     DNA for randu_out.rbnf  using bits 13 to 14       1047580******* 1.0000
     DNA for randu_out.rbnf  using bits 12 to 13       1047580******* 1.0000
     DNA for randu_out.rbnf  using bits 11 to 12       1047580******* 1.0000
     DNA for randu_out.rbnf  using bits 10 to 11       1047580******* 1.0000
     DNA for randu_out.rbnf  using bits  9 to 10       1047580******* 1.0000
     DNA for randu_out.rbnf  using bits  8 to  9       1047580******* 1.0000
     DNA for randu_out.rbnf  using bits  7 to  8       1047580******* 1.0000
     DNA for randu_out.rbnf  using bits  6 to  7       1047580******* 1.0000
     DNA for randu_out.rbnf  using bits  5 to  6       1047580******* 1.0000
     DNA for randu_out.rbnf  using bits  4 to  5       1047580******* 1.0000
     DNA for randu_out.rbnf  using bits  3 to  4       1047580******* 1.0000
     DNA for randu_out.rbnf  using bits  2 to  3       1047580******* 1.0000
     DNA for randu_out.rbnf  using bits  1 to  2       1047580******* 1.0000

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::     This is the COUNT-THE-1's TEST on a stream of bytes.      ::        
     :: Consider the file under test as a stream of bytes (four per   ::        
     :: 32 bit integer).  Each byte can contain from 0 to 8 1's,      ::        
     :: with probabilities 1,8,28,56,70,56,28,8,1 over 256.  Now let  ::        
     :: the stream of bytes provide a string of overlapping  5-letter ::        
     :: words, each "letter" taking values A,B,C,D,E. The letters are ::        
     :: determined by the number of 1's in a byte::  0,1,or 2 yield A,::        
     :: 3 yields B, 4 yields C, 5 yields D and 6,7 or 8 yield E. Thus ::        
     :: we have a monkey at a typewriter hitting five keys with vari- ::        
     :: ous probabilities (37,56,70,56,37 over 256).  There are 5^5   ::        
     :: possible 5-letter words, and from a string of 256,000 (over-  ::        
     :: lapping) 5-letter words, counts are made on the frequencies   ::        
     :: for each word.   The quadratic form in the weak inverse of    ::        
     :: the covariance matrix of the cell counts provides a chisquare ::        
     :: test::  Q5-Q4, the difference of the naive Pearson sums of    ::        
     :: (OBS-EXP)^2/EXP on counts for 5- and 4-letter cell counts.    ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
   Test results for randu_out.rbnf 
 Chi-square with 5^5-5^4=2500 d.of f. for sample size:2560000
                               chisquare  equiv normal  p-value
  Results fo COUNT-THE-1's in successive bytes:
 byte stream for randu_out.rbnf ********* 579173.600     1.000000
 byte stream for randu_out.rbnf ********* 579286.100     1.000000

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::     This is the COUNT-THE-1's TEST for specific bytes.        ::        
     :: Consider the file under test as a stream of 32-bit integers.  ::        
     :: From each integer, a specific byte is chosen , say the left-  ::        
     :: most::  bits 1 to 8. Each byte can contain from 0 to 8 1's,   ::        
     :: with probabilitie 1,8,28,56,70,56,28,8,1 over 256.  Now let   ::        
     :: the specified bytes from successive integers provide a string ::        
     :: of (overlapping) 5-letter words, each "letter" taking values  ::        
     :: A,B,C,D,E. The letters are determined  by the number of 1's,  ::        
     :: in that byte::  0,1,or 2 ---> A, 3 ---> B, 4 ---> C, 5 ---> D,::        
     :: and  6,7 or 8 ---> E.  Thus we have a monkey at a typewriter  ::        
     :: hitting five keys with with various probabilities::  37,56,70,::        
     :: 56,37 over 256. There are 5^5 possible 5-letter words, and    ::        
     :: from a string of 256,000 (overlapping) 5-letter words, counts ::        
     :: are made on the frequencies for each word. The quadratic form ::        
     :: in the weak inverse of the covariance matrix of the cell      ::        
     :: counts provides a chisquare test::  Q5-Q4, the difference of  ::        
     :: the naive Pearson  sums of (OBS-EXP)^2/EXP on counts for 5-   ::        
     :: and 4-letter cell counts.                                     ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
 Chi-square with 5^5-5^4=2500 d.of f. for sample size: 256000
                      chisquare  equiv normal  p value
  Results for COUNT-THE-1's in specified bytes:
           bits  1 to  8*********2022919.000     1.000000
           bits  2 to  9*********2024444.000     1.000000
           bits  3 to 10*********2022877.000     1.000000
           bits  4 to 11*********2024529.000     1.000000
           bits  5 to 12*********2022702.000     1.000000
           bits  6 to 13*********2024642.000     1.000000
           bits  7 to 14*********2022632.000     1.000000
           bits  8 to 15*********2024575.000     1.000000
           bits  9 to 16*********2022714.000     1.000000
           bits 10 to 17*********2024586.000     1.000000
           bits 11 to 18*********2022687.000     1.000000
           bits 12 to 19*********2024626.000     1.000000
           bits 13 to 20********* 500841.800     1.000000
           bits 14 to 21*********  75988.340     1.000000
           bits 15 to 22975377.00  13758.560     1.000000
           bits 16 to 23378613.60   5319.049     1.000000
           bits 17 to 24232668.00   3255.066     1.000000
           bits 18 to 25293615.60   4116.996     1.000000
           bits 19 to 26428343.20   6022.332     1.000000
           bits 20 to 27738129.10  10403.370     1.000000
           bits 21 to 28*********  18892.250     1.000000
           bits 22 to 29*********  37849.360     1.000000
           bits 23 to 30*********  65135.280     1.000000
           bits 24 to 31********* 101677.500     1.000000
           bits 25 to 32********* 216174.100     1.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 ten tests on file randu_out.rbnf 
            Of 12,000 tries, the average no. of successes
                 should be 3523 with sigma=21.9
            Successes:    1    z-score:******* p-value: .000000
            Successes:    1    z-score:******* p-value: .000000
            Successes:    1    z-score:******* p-value: .000000
            Successes:    1    z-score:******* p-value: .000000
            Successes:    1    z-score:******* p-value: .000000
            Successes:    1    z-score:******* p-value: .000000
            Successes:    1    z-score:******* p-value: .000000
            Successes:    1    z-score:******* p-value: .000000
            Successes:    1    z-score:******* p-value: .000000
            Successes:    1    z-score:******* p-value: .000000
 
           square size   avg. no.  parked   sample sigma
             100.               1.000         .000
            KSTEST for the above 10: p= 1.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 random integers in the file randu_out.rbnf 
     Sample no.    d^2     avg     equiv uni            
           5     .0000    .0000     .000000
          10     .0000    .0000     .000000
          15     .0000    .0000     .000000
          20     .0000    .0000     .000000
          25     .0000    .0000     .000000
          30     .0000    .0000     .000000
          35     .0000    .0000     .000000
          40     .0000    .0000     .000000
          45     .0000    .0000     .000000
          50     .0000    .0000     .000000
          55     .0000    .0000     .000000
          60     .0000    .0000     .000000
          65     .0000    .0000     .000000
          70     .0000    .0000     .000000
          75     .0000    .0000     .000000
          80     .0000    .0000     .000000
          85     .0000    .0000     .000000
          90     .0000    .0000     .000000
          95     .0000    .0000     .000000
         100     .0000    .0000     .000000
     MINIMUM DISTANCE TEST for randu_out.rbnf 
          Result of KS test on 20 transformed mindist^2's:
                                  p-value=1.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 randu_out.rbnf 
 sample no:  1     r^3=    .000     p-value= .00000
 sample no:  2     r^3=    .000     p-value= .00000
 sample no:  3     r^3=    .000     p-value= .00000
 sample no:  4     r^3=    .000     p-value= .00000
 sample no:  5     r^3=    .000     p-value= .00000
 sample no:  6     r^3=    .000     p-value= .00000
 sample no:  7     r^3=    .000     p-value= .00000
 sample no:  8     r^3=    .000     p-value= .00000
 sample no:  9     r^3=    .000     p-value= .00000
 sample no: 10     r^3=    .000     p-value= .00000
 sample no: 11     r^3=    .000     p-value= .00000
 sample no: 12     r^3=    .000     p-value= .00000
 sample no: 13     r^3=    .000     p-value= .00000
 sample no: 14     r^3=    .000     p-value= .00000
 sample no: 15     r^3=    .000     p-value= .00000
 sample no: 16     r^3=    .000     p-value= .00000
 sample no: 17     r^3=    .000     p-value= .00000
 sample no: 18     r^3=    .000     p-value= .00000
 sample no: 19     r^3=    .000     p-value= .00000
 sample no: 20     r^3=    .000     p-value= .00000
  A KS test is applied to those 20 p-values.
---------------------------------------------------------
       3DSPHERES test for file randu_out.rbnf       p-value=1.000000
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     ::      This is the SQEEZE test                                  ::        
     ::  Random integers are floated to get uniforms on [0,1). Start- ::        
     ::  ing with k=2^31=2147483647, the test finds j, the number of  ::        
     ::  iterations necessary to reduce k to 1, using the reduction   ::        
     ::  k=ceiling(k*U), with U provided by floating integers from    ::        
     ::  the file being tested.  Such j's are found 100,000 times,    ::        
     ::  then counts for the number of times j was <=6,7,...,47,>=48  ::        
     ::  are used to provide a chi-square test for cell frequencies.  ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
            RESULTS OF SQUEEZE TEST FOR randu_out.rbnf 
         Table of standardized frequency counts
     ( (obs-exp)/sqrt(exp) )^2
        for j taking values <=6,7,8,...,47,>=48:
    -1.5    -2.4    -4.2    -6.8   -10.5   -15.4
   -21.5   -28.7   -36.9   -45.8   -54.9   -63.9
   -72.1   -79.3   -84.9   -88.7   -90.6   -90.5
   -88.6   -85.0   -80.0   -74.0   -67.2   -60.1
   -52.9   -37.1  1539.5   334.4   281.4   210.0
   201.9   177.2    91.7   122.6    49.4   140.7
    91.6   123.1    -2.4    -1.8    -1.3    -1.0
   382.4
           Chi-square with 42 degrees of freedom:*******
              z-score=*******  p-value=1.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. The  p-values from ten     ::        
     :: KSTESTs are given still another KSTEST.                       ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
                Test no.  1      p-value 1.000000
                Test no.  2      p-value 1.000000
                Test no.  3      p-value 1.000000
                Test no.  4      p-value 1.000000
                Test no.  5      p-value 1.000000
                Test no.  6      p-value 1.000000
                Test no.  7      p-value 1.000000
                Test no.  8      p-value 1.000000
                Test no.  9      p-value 1.000000
                Test no. 10      p-value 1.000000
   Results of the OSUM test for randu_out.rbnf 
        KSTEST on the above 10 p-values: 1.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 ::        
     :: repeated.                                                     ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
           The RUNS test for file randu_out.rbnf 
     Up and down runs in a sample of 10000
_________________________________________________ 
                 Run test for randu_out.rbnf :
       runs up; ks test for 10 p's:1.000000
     runs down; ks test for 10 p's:1.000000
                 Run test for randu_out.rbnf :
       runs up; ks test for 10 p's:1.000000
     runs down; ks test for 10 p's:1.000000

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
     :: This is the CRAPS TEST. It plays 200,000 games of craps, finds::        
     :: the number of wins and the number of throws necessary to end  ::        
     :: each game.  The number of wins should be (very close to) a    ::        
     :: normal with mean 200000p and variance 200000p(1-p), with      ::        
     :: p=244/495.  Throws necessary to complete the game can vary    ::        
     :: from 1 to infinity, but counts for all>21 are lumped with 21. ::        
     :: A chi-square test is made on the no.-of-throws cell counts.   ::        
     :: Each 32-bit integer from the test file provides the value for ::        
     :: the throw of a die, by floating to [0,1), multiplying by 6    ::        
     :: and taking 1 plus the integer part of the result.             ::        
     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::        
                Results of craps test for randu_out.rbnf 
  No. of wins:  Observed Expected
                               140155    98585.86
                 140155= No. of wins, z-score=****** pvalue=1.00000
   Analysis of Throws-per-Game:
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'hycrotan 'nonBinary))
Image

User avatar
pixelfck
Militia Captain
Militia Captain
Posts: 571
Joined: Tue Aug 11, 2009 8:47 pm
Location: Travelling around in Europe

Sun Oct 13, 2013 9:57 am

Nice to see those results. I'm a bit surprised by the failure of the .net rng. I would think that by now a standard rng would provide better quality output.
I'm most happy to see that my seededRandom is not that bad, although it seems that it is not particularly good either :)

It seems you put a lot more work in your, I'll take a better look at it later today.

Cheers,
Pixelfck
Image
Download the Black Market Expansion from Xelerus.de today!
My other mods at xelerus.de

User avatar
Wolfy
Fleet Admiral
Fleet Admiral
Posts: 5351
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

Sun Oct 13, 2013 2:48 pm

For its speed, its great - Generally failing one test with a simple fast algorithm isnt bad - I was working on getting mine to produce a distribution of p-values that were appropriate (ie, a combination that should only happen 10% of the time should only happen ~10% of the time, etc), but at the cost of it plodding along slowly.
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'hycrotan 'nonBinary))
Image

Locked