Categories
BLOG

predict random numbers

Is it possible to predict the next number in a number generator? [closed]

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 7 years ago .

With programming, it is never “random”. Even the random generator uses an algorithm to predict a random number. But, if knowing the method of generation, is it possible to, let’s say predict next 5 numbers that will be generated?

16GB. – Mooing Duck Jun 28 ’13 at 19:22

2*10^19935 bytes. For a sense of scale, there are approx

2*10^82 atoms in the obvervable universe. – Mooing Duck Jun 28 ’13 at 19:28

3 Answers 3

Yes, it is possible to predict what number a random number generator will produce next. I’ve seen this called cracking, breaking, or attacking the RNG. Searching for any of those terms along with “random number generator” should turn up a lot of results.

Read How We Learned to Cheat at Online Poker: A Study in Software Security for an excellent first-hand account of how a random number generator can be attacked. To summarize, the authors figured out what RNG was being used based on a faulty shuffling algorithm employed by an online poker site. They then figured out the RNG seed by sampling hands that were dealt. Once they had the algorithm and the seed, they knew exactly how the deck would be arranged after later shuffles.

Is it possible to predict the next number in a number generator? [closed] Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 7

How To Predict Outcome Of Random Number Generator

Can one develop a code to predict the outcome of random number generator by simply using the last outputted result? By this, I mean if it is possible to guess which integer comes out first, second, third, etc of a machine that produces random integers, in the range, say 1 to 100 by using the previous outputted result according to the way it produced them one after the other. The machine in question produces the numbers(1 To 100) one after the other randomly until all the numbers appear. Next time when it is operated, it produces stream of random integers in the same range (1 To 100), but they differ in arrangement, the numbers appear one after the other till the whole 100 integers appear.

11 Answers

  • Active
  • Voted
  • Newest
  • Oldest

Is this a trick question? A random number generator is not a random number generator if you can predict the output based on the last output. The definition of random would be violated. Thus you have MS telling you that the normal rand() function is a pseudo random number generator as the pattern will repeat unless reseeded.

If the numbers you get from the “random number generator” are guaranteed to produce all 100 possible values before repeating, THEY ARE NOT RANDOM.

Michael S. Meyers-Jouan

> Dominic, If the numbers you get from the “random number generator” are guaranteed
> to produce all 100 possible values before repeating, THEY ARE NOT RANDOM.

Correct answer. What the original poster really wants is a permutation of numbers from 1 to 100.

For Perfectaffairs: a permutation is a sequence containing each element from a finite set once, and only once. It is by definition not random.

Sir, I believe you that they are not random if it is guaranteed to produce all the possible values before repeating. Then, can it be predicted because the machine produces all the numbers before repeating. Once started, all the numbers must appear when the operation button is hit 100 times. Please give me the code to predict the next outcome. that is, which number comes first, second, third,etc etc

Thank you very much.

If you are saying that you want the second set of numbers to match the first random set of numbers, you can run the random generator on startup and capture it into an array of integers. Then you can use the array to generate the next iterations of the sequence.

What you see below is not meant to be pure code, but just an idea of how to make your random numbers predictable.

If you are looking for a mixed sequence of integers from 1 to 100 that always run in the same order and can’t get the random generator to not repeat a number before getting to 100, then you could generate a mixed sequence of integers yourself by maybe running a loop from 1 to 10 and using a MixedArray(1 to 10) to multiply each iteration by the loop’s index. RandomArray(1 to 100) = LoopValue times MixedArray(LoopValue) “get the first ten integers” then increase loopValue and multiply the second value through the loop and “get the next ten integers” into the RandomArray(1 to 100) increasing the RandomArray index with each iteration of the loop up to 100.

By setting the MixedArray(1 to 10) with a set of numbers that you select, you can control the way the numbers are generated into RandomArray(1 to 100).

Example: set MixedArray(1 to 10) to a sequence of 1,3,5,7,9,2,4,6,8,10 and see what the loop generates.

Putting the numbers into RandomArray(1 to 100) is just so you don’t have to run the loop each time you need a number. You can keep a floating Value for the next number you need and use it as an index for the Random Array.

I hope this helped a little! I tend to ramble. This is what I do when I want to generate random numbers and need to know the final sequence.

Can one develop a code to predict the outcome of random number generator by simply using the last outputted result? By this, I mean if it is possible to gues… ]]>