# Can machine learning analyze random number generator?

I'm studying for random number generators(RNG) and I saw about machine learning a few days ago. So I searched analysis of RNG using machine learning. But I couldn't find such fields. Are there such examples for analysis of RNG using machine learning? No matter some papers of articles.

• Are you asking if machine learning could analyze THE OUTPUT of a (P)RNG? Or if machine learning could analyze THE DEFINITION of a PRNG?
– fgrieu
Mar 26 '15 at 15:50
• Exactly, I meant that target is THE OUTPUT of PRNG. There are many method to determine randomness of output string. So I just wonder if I can predict some of strings using concept of machine learning. Mar 27 '15 at 8:57

The goal of an ideal cryptographically secure pseudo-random number generator (CSPRNG) is to produce a stream of numbers that no machine can distinguish from a truly random stream of numbers. Formally, it's impossible unknown whether it's possible to prove that a CSPRNG is truly random.

That being said, there exists a family of statistical tests that can measure whether a sequence of numbers appears to be uniformly random, and produce a probabilistic analysis as output. I'm not sure if these tests qualify as related to machine learning, but here are some examples:

If you are interested in trying out a CSPRNG, you can use:

• AES-CTR with a random key acting as the seed.
• Under Linux, Mac OS X, BSD, /dev/urandom.
• window.crypto.getRandomValues() in your browser console (Chrome, Firefox).

Note that not all PRNGs are CSPRNGs.

• I'm pretty sure those tests are not considered "machine learning". Mar 26 '15 at 15:49
• Shrug I thought so as well, but hopefully my answer can be somewhat helpful either way. Mar 26 '15 at 15:54
• It's good background info, I'm not sure if it qualifies as an answer. AES-CTR is close but not quite a CSPRNG I guess, it does not offer re-seed possibilities for instance. Mar 26 '15 at 16:10
• You can transform a block cipher in CTR mode into a RNG using NIST's CTR_DRBG, I'm pretty sure. Mar 27 '15 at 2:28

Consider the limitations of such an analysis. It can summarily reject a PRNG as being insufficiently random by demonstrating that the outputs are predictable by a computer program. However, its ability to generate comfort as to the randomness of a PRNG is limited. We have mathematicians going through hoops with months of mathematical analysis to prove that a flaw exists, much less find the flaw outright. Often a "broken" algorithm is shown to break after petabyes of random numbers, which becomes an indication that it will continue to be attacked in less and less time, until any old laptop can break it. Those studying PRNGs would want a little more warning than "a computer program has actually cracked it."

It might be interesting to use such machine learning programs for high performance PRNGs that do not have any cryptographic guarantees. They might be able to help explain to a programmer or artist the limitations of a particular PRNG choice for their particular job, rather than relying on highly abstract measures of unpredictability.

The NIST test suite for random numbers implements "short-term memory" machine learning algorithms.

It needs to save and categorize all relevant data to be "long-term memory" machine learning.

You may use binary classification algorithm like decision tree and have two learning data sets one which has the truly random bytes and the other puesudo random bytes. As you might probably know, you have to specify the size of every record say for example 1k.

It is really a good idea.

• This (probably) won't work. There is certainly structure in CSPRNG's that could potentially be exploited, but I don't believe naive classification will be powerful enough to yield a distinguisher for any nontrivial CSPRNG. Oct 3 '15 at 11:17