I'm referring to a program called ent
that is commonly used to test the quality of random number generators. I'm trying to improve it. The following is a typical result (and a good pass):-
$ ent /tmp/urandom-500MB
Entropy = 8.000000 bits per byte.
Optimum compression would reduce the size
of this 524288000 byte file by 0 percent.
Chi square distribution for 524288000 samples is 264.86, and randomly
would exceed this value 32.26 percent of the times.
Arithmetic mean value of data bytes is 127.4993 (127.5 = random).
Monte Carlo value for Pi is 3.141621289 (error 0.00 percent).
Serial correlation coefficient is 0.000036 (totally uncorrelated = 0.0).
Please note the result for the Chi square distribution. The program offers a likelihood of the result (of 32.26%) occurring by chance. That's a p value.
Now please note the results for the arithmetic mean of the bytes, and the Monte Carlo calculation for Pi. This is obtained by taking the input sequence bytes in tuples of three for an x coordinate, and three for a y coordinate, and performing this type of Pi approximation.
Q: How can we add likelihood percentages to both arithmetic mean and Pi calculations?
So for example, I want functionality that says: Arithmetic mean value of data bytes is 127.4993, and randomly would exceed this value xx.xx percent of the time.
And similarly for the Pi approximation.
This is an example of a similar test, and how it's derived:-
10 - Parking Lot Test (modified).
This tests the distribution of attempts to randomly park a square car of length 1 on a 100x100 parking lot without crashing. We plot n (number of attempts) versus k (number of attempts that didn't "crash" because the car squares overlapped and compare to the expected result from a perfectly random set of parking coordinates. This is, alas, not really known on theoretical grounds so instead we compare to n=12,000 where k should average 3523 with sigma 21.9 and is very close to normally distributed. Thus (k-3523)/21.9 is a standard # normal variable, which converted to a uniform p-value, provides input to a KS test with a default 100 samples.
which is the test description from the dieharder
randomness test suite, here. To my mind this is not light years away from the Pi test. This parking lot test suggests that they had to compute the statistics by simulation, rather than arithmetically.