Can neural network find connections beetween numbers generated by random number generator without knowing about it's seed and predict this rng's next numbers with more sucess then randomly guessing? I really couldn't find any data about this. Thanks


3 Answers 3


Depends heavily on how you are trying to make the prediction.

Most PRNGs that I've used usually operate on a ring of numbers within a finite range. The seed decides what number you start on, and you progress around the ring one number at a time. The order of the numbers appears random, but their order is actually very deterministic.

For example, lets say that your prng generates numbers on the ring 0-6. If your seed is 1, then it might cycle through numbers in this way:

1 -> 6 -> 2 -> 4 -> 0 -> 3 -> 5 -> 1 -> 6 -> ...

Some important things to note:

  • Once you reach the seed again, the values repeat.
  • Apparent randomness is achieved by generating a ring that appears to "scatter" numbers around and choosing a different seed every time you run the generator.

When looking at it in this respect, it is actually quite easy to predict the next random number that comes from a typical prng--all you need to know is the function that generated the ring of numbers and the last number that was pulled from the sequence.

After reading this, it might be tough to understand why the numbers appear random in the first place (especially when looking at the sequence above). The thing to understand is that the range of numbers is usually enormous (on the scale of 2^31-ish), and therefore it is EXTREMELY unlikely that you will land in the same section of the ring on subsequent runs of the program.

So depending on your situation, what you are doing could be quite easy--if you know the function that is generating the sequence of numbers, then all you need is the last number pulled and you're done! No neural network needed.

If you don't know the function that generates the ring of numbers, then it is very unlikely that a neural network will help. The function that generates the cycle of numbers is designed to be a one-way function (a.k.a., you can't invert the function to figure out the values used within the function).

If you're interested in pursuing this further, I highly recommend that you study PRNG's in depth. The math is fairly simple, and knowing how they work will give you a better idea of what their strengths and limitations are.

  • This answer seems to mix seed, state and outcome of a RNG. In general, the initial state is a function of the seed, state evolves by repeatedly applying a function to it, and the outcome is determined by yet another function to the state. In a good RNG, the state space is a lot larger than the output domain, so one output can be the result of many different states. In turn that means you can't predict the state nor the next outcome from a single outcome.
    – MSalters
    Mar 11, 2015 at 16:02
  • @MSalters, you most certainly can predict the state as long as you know the details of the algorithm and have a large number of outcomes to analyze. PRNG's are never judged or analyzed based on a single outcome.
    – riwalk
    Mar 12, 2015 at 16:25
  • About "if you know the function that is generating the sequence of numbers, then all you need is the last number pulled and you're done" , if it can't produce same number twice in a row, it's so low quality I would not call it PRNG... Entire internal state is needed, last number pulled isn't ever enough. If there is no internal state, it's not a real PRNG. I'd edit that sentence a bit.
    – hyde
    Sep 9, 2017 at 12:09
  • Of course it is also a matter of definitions. I feel this link is somehow relevant: xkcd.com/221
    – hyde
    Sep 9, 2017 at 12:24

If the random number generator is reasonably good, it is impossible to predict the Nth number given only the prior N-1 numbers. Any random number generator that is used for cryptographic purposes, for example, will be sufficiently random that you won't be able to predict the next number.

If you've got a poor random number generation, on the other hand, it may be possible to predict the Nth number so it should be possible for a neural net to predict the next number (depending, of course, on the weakness of the random number generator).


Most likely, no.

The universal approximation theorem and its extensions only cover integrable functions, which random number generators are not a class of.

Future mathematics may be able to show that any function is approximatable, but not current mathematics.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.