1
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ Could you please explain what "add likelihood percentages" might mean? One interpretation is that the value reported for the chi-squared test is a p value and you are requesting p-values for the (implicit) tests of the arithmetic mean and $\pi$ simulation. The description of the parking lot test looks irrelevant: you don't seem to be reporting its results or asking about it. $\endgroup$
    – whuber
    Commented Jan 16, 2022 at 16:25
  • $\begingroup$ Thank you for the edits. It looks like you are asking how to compute p-values for a battery of tests. Each one is different and likely requires a different answer. In many cases you can find answers already here: for instance, testing a mean is a textbook problem answered extensively here and elsewhere. Consider, then, describing a particular test in which you are interested, have researched, and have not been able to find an answer. $\endgroup$
    – whuber
    Commented Jan 17, 2022 at 15:26
  • $\begingroup$ @whuber Well that was a waste of time wasn't it? $\endgroup$
    – Paul Uszak
    Commented Jan 17, 2022 at 17:13

0