Why do statistical randomness tests seem so ad hoc? - MathOverflow most recent 30 from http://mathoverflow.net 2013-05-22T07:08:53Z http://mathoverflow.net/feeds/question/37518 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://mathoverflow.net/questions/37518/why-do-statistical-randomness-tests-seem-so-ad-hoc Why do statistical randomness tests seem so ad hoc? Jason Orendorff 2010-09-02T17:53:09Z 2010-09-03T11:39:35Z <p>Wikipedia describes <a href="http://en.wikipedia.org/wiki/Statistical_randomness#Tests" rel="nofollow">Kendall and Smith's 1938 statistical randomness tests</a> like this:</p> <blockquote> <ul> <li><p>The <b>frequency test</b>, was very basic: checking to make sure that there were roughly the same number of 0s, 1s, 2s, 3s, etc.</p></li> <li><p>The <b>serial test</b>, did the same thing but for sequences of two digits at a time (00, 01, 02, etc.), comparing their observed frequencies with their hypothetical predictions were they equally distributed.</p></li> <li><p>The <b>poker test</b>, tested for certain sequences of five numbers at a time (aaaaa, aaaab, aaabb, etc.) based on hands in the game poker.</p></li> <li><p>The <b>gap test</b>, looked at the distances between zeroes (00 would be a distance of 0, 030 would be a distance of 1, 02250 would be a distance of 3, etc.).</p></li> </ul> </blockquote> <p>It is not obvious to me that these four particular tests were chosen with any deep understanding of how best to detect nonrandomness. Rather, it seems each one was probably chosen for simplicity.</p> <p>Well, it's easy to see why early work in the field would be like that. But fast forward to 1995 and George Marsaglia's <a href="http://en.wikipedia.org/wiki/Diehard_tests" rel="nofollow">Diehard tests</a> seem, on the surface, just as ad hoc:</p> <blockquote> <ul> <li><p><b>Birthday spacings:</b> Choose random points on a large interval. The spacings between the points should be asymptotically Poisson distributed. The name is based on the birthday paradox.</p></li> <li><p><b>Overlapping permutations:</b> Analyze sequences of five consecutive random numbers. The 120 possible orderings should occur with statistically equal probability.</p></li> </ul> <p><em>(...and so on)</em></p> </blockquote> <p>It is not obvious to me that these tests are really independent (i.e. that none is entirely redundant, rejecting only sequences also rejected by at least one of the other tests), or that there aren't obviously better generalizations of them, much less that they were chosen as a set to try to cover any particular space efficiently.</p> <p>Ideally, a test suite would be designed to reject as many sequences of low Kolmogorov complexity as possible with minimal computation and false alarms. Is a more theoretical approach to this possible? Why hasn't it happened? &mdash;Or is there more to the state of the art than meets the eye?</p> http://mathoverflow.net/questions/37518/why-do-statistical-randomness-tests-seem-so-ad-hoc/37523#37523 Answer by Yaroslav Bulatov for Why do statistical randomness tests seem so ad hoc? Yaroslav Bulatov 2010-09-02T18:39:09Z 2010-09-02T18:39:09Z <p>Kolmogorov complexity is a universal quantity for infinite strings. But since randomness tests are run on finite strings, particular choice of architecture or encoding will play a large role in how the strings will be ordered. A goal of good randomness test designer is to choose an encoding such that strings coming from known random sources (like random.org) are deemed more complex than strings coming from known non-random sources (like pseudo-random generators). Good tests incorporate knowledge of how typical non-random strings are generated, hence the apparent ad hockery.</p> http://mathoverflow.net/questions/37518/why-do-statistical-randomness-tests-seem-so-ad-hoc/37526#37526 Answer by Thierry Zell for Why do statistical randomness tests seem so ad hoc? Thierry Zell 2010-09-02T19:04:56Z 2010-09-02T19:04:56Z <p>In Chapter 2 of the book <em>Group Theory in the Bedroom</em>, Brian Hayes mentions how difficult it is to extract "true" randomness from the physical world (including constructing tables of random numbers the old-fashioned way, and how Fisher and Yates had to "fix" their tables in post-processing to re-balance the digits, causing their colleagues to comment: <em>"a procedure of this kind may cause others, as it did us, some misgivings"</em>).</p> <p>The point he makes is that physical randomness is hard to achieve, because even if your source is truly random (whatever that means), the measurement process is apt to introduce bias, so that pseudo-random generators can out-perform physical random sources on many statistical test. <em>[I'll add a more precise page reference as soon as I can find it.]</em></p> <p>Given this state of affairs, the ideal test suite seems unlikely to exist. I would agree with you that less ad-hoc tests do seem desirable, though.</p> http://mathoverflow.net/questions/37518/why-do-statistical-randomness-tests-seem-so-ad-hoc/37557#37557 Answer by Peter Shor for Why do statistical randomness tests seem so ad hoc? Peter Shor 2010-09-02T23:11:39Z 2010-09-03T11:39:35Z <p>It's not clear that Marsaglia's tests are really good enough. See <a href="http://stackoverflow.com/questions/584566/pseudo-random-number-generator">this Stack Overflow discussion</a>.</p> <p>Kolmogorov complexity is not the right criterion for statistical randomness tests, since any pseudorandom sequence has low Kolmogorov complexity. What you really want in a random number generator is for the sequence to be computationally pseudorandom; that is, without knowledge of the seed, no polynomial-time test can distinguish the sequence from a truly random sequence. </p> <p>In fact, there are a number of random number generators which are believed to be computationally pseudorandom. Nobody uses these, however, partly because they are computationally too expensive, and partly because of inertia and partly because the existing pseudorandom generators we have are good enough most of the time. A while ago, for one of the most common methods of pseudorandom number generation (linear congruential), I ran into cases where they unexpectedly produced the wrong answer.</p> <p>Marsaglia's tests were developed over a number of years, and I believe each was designed to detect certain flaws that many pseudorandom number generators contained at the time. Once good-enough pseudorandom number generators were available, nobody bothered creating a more stringent series of tests.</p>