How can I accurately predict the next random number between 1 and 999, given past results. I have no knowledge of the PRNG or algorithm used.

How can I predict the next number of a long sequence of seemingly random numbers? Can I do it by hand, or should I use some kind of software to help find patterns from long strings of data?


closed as too broad by fgrieu, CodesInChaos, DrLecter, tylo, AFS Jan 21 '14 at 19:11

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ if it uses a proper CSPRNG, you may need billions of samples to find a pattern. knowing if you can even find one would help $\endgroup$ – Richie Frame Jan 21 '14 at 10:25
  • $\begingroup$ whats the cs mean? sorry im fairly new to this, lets just say its your run of the mill PRNG. $\endgroup$ – C.B. Dooper Jan 21 '14 at 10:30
  • $\begingroup$ Cryptographically Secure, most of the time implemented with a secure hash of an entropy pool that gets mixed in again for the next round $\endgroup$ – ratchet freak Jan 21 '14 at 11:30
  • $\begingroup$ You said "I have no knowledge of the prng or algorithm used". This means, that you are potentially facing a very weak or very strong algorithm. However, finding out what algorithm is used is out of scope of cryptography. IF(!) it is a weak algorithm (e.g. a LCG), you might be lucky with statistical analysis. If it is a strong one, there is basically no way you can find out which one (except trying out every possible algorithm with every possible starting parameter and run it for the entire period). $\endgroup$ – tylo Jan 21 '14 at 14:05
  • $\begingroup$ More than that - you are potentially facing true random data... $\endgroup$ – figlesquidge Jan 21 '14 at 16:09

This sounds like a lot of work.

I would break this down into parts. First, I would try to identify the random number generator being used. From that, my goal would be to determine the starting seed, which would let me accurately predict future results based on past results.

I'd start with the NIST Random Number Generation statistical tests In them, they offer 15 statistical tests for a random number generator. I'd run the sample data through this battery of tests to see if it's actually random or not. Important: if the tests reveal it is random, that could be evidence that a cryptographically secure random number generator was used to produce them. I would stop searching as I would consider the problem unsolvable at that point.

I'd then test each of the random number generators that the original source might have used, such as rand(), and see if they reveal a pattern similar to that output of the mystery algorithm.

Once a potential random number generator is identified, I'd turn to published papers to see what kinds of analysis and reversals are known for it.


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