Answers.Body: <p>Assuming the random numbers are being generated by an unknown random number generator that is practically indistinguishable from a &quot;true&quot; random source, then the answers are:</p>
  <blockquote>
  <p>Is it possible predict the next number in the stream knowing the PDF and the stream?</p>
  </blockquote>
  <p>No, this is either completely impossible even in theory, or a practical impossibility for most modern PRNGs. By practical impossibility I mean you would need to collect some huge number of samples e.g. <span class="math-container">$2^{128}$</span> and it would take longer than the lifetime of the universe and use up more energy than the suns output over its entire lifetime.</p>
  <blockquote>
  <p>What kind of approach could be taken?</p>
  </blockquote>
  <p>None, it is impossible, and AI won't help.</p>
  <p>What if the random number generator was not so good . . .</p>
  <p>Poorly designed random number generators can be predicted. Really old ones might fall to statistical analysis, and you could even train something like an LSTM to predict the next number in the sequence. This has nothing to do with the PDF, although you will need to reverse-engineer how the PDF is being produced in order to get at the raw PRNG outputs for analysis. Also, almost no modern computer language or library uses a random number function that is so simple.</p>
  <p>For modern but insecure generators, such as the Mersenne Twister algorithm if you know or can reverse-engineer the algorithm being used, sometimes it may be possible to infer the current state of a random number generator from a certain number of samples. This is not really an AI issue though, but more closely related to cryptography. I believe the minimum number of samples to infer Mersenne Twister state is something like 640.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-23T23:25:17.200Z
Answers.Text: Thank you for the response, very helpful. Now, what if we shift the goal from predicting the values, to predicting the range in which the next value will fall? Assuming we have N bins, would decreasing the size of N make the problem more "approachable" ? Or would it still be impossible? @Neil Slater
Answers.UserDisplayName: Luk
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-24T00:06:35.633Z
Answers.Text: If it's a true random number generator, then there is no way to "predict" the next number, the next bin, or next anything. By definition, if it's random there should be no information available about it until you see the number.
Answers.UserDisplayName: programjames
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-24T00:08:09.063Z
Answers.Text: However, it's rare that you *actually* have random numbers. For example, Microsoft thought [PhotoDNA](https://anishathalye.com/inverting-photodna/) hashes were random enough, until they got inverted with the help of neural networks.
Answers.UserDisplayName: programjames
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-24T06:06:43.333Z
Answers.Text: If it is enough to predict it going in a certain bin it can be feasible for pseudorandom variables. I remember having a huge excel that showed the drop rate of an item in a chest in an rpg based on what value the cure magic had in battle or something like that...
Answers.UserDisplayName: Emil
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-24T07:28:41.883Z
Answers.Text: @luk it would still be impossible. Although your accuracy would improve. E.g. if there was one bin from the pdf which contained 50% of the probability, then you could predict that the next number would be in that bin with 50% accuracy.
Answers.UserDisplayName: Neil Slater
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-24T08:05:59.603Z
Answers.Text: @Emil: You can always predict a probability that matches the probability derived from the PDF. This is normal in machine learning, where the "residual" unknown factors impact prediction accuracy, but you can still often make predictions that are useful (effectively the ML learns the PDF, or at least the value to predict from it that leads to lowest error). It is also very different from "hacking" an underlying PRNG, which would have to be very low quality to achieve results using ML.
Answers.UserDisplayName: Neil Slater
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-23T22:55:22.483Z
Answers.LastActivityDate: 2024-04-23T23:01:17.067Z
Answers.LastEditDate: 2024-04-23T23:01:17.067Z
Answers.UserDisplayName: Neil Slater
Body: <p>Lets say we have an arbitrarily large stream of numbers, numbers ranging from 1 to 100. You know these numbers follow a known distribution, e.g exponential distribution.</p>
  <p>Is it possible predict the next number in the stream knowing the PDF and the stream? What kind of approach could be taken?</p>
  
Tags: <regression>
Title: Is it possible to predict the next number in a stream that comes from a known PDF?
UserDisplayName: Luk
ThreadText: # Is it possible to predict the next number in a stream that comes from a known PDF?
  
  (Asked by: username_0 on 2024-04-23)
  
  Lets say we have an arbitrarily large stream of numbers, numbers ranging from 1 to 100. You know these numbers follow a known distribution, e.g exponential distribution.
  
  Is it possible predict the next number in the stream knowing the PDF and the stream? What kind of approach could be taken?
  
  **Tags:** regression
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-04-23. Score: 2
  
  Assuming the random numbers are being generated by an unknown random number generator that is practically indistinguishable from a "true" random source, then the answers are:
  
  > Is it possible predict the next number in the stream knowing the PDF and the stream?
  
  No, this is either completely impossible even in theory, or a practical impossibility for most modern PRNGs. By practical impossibility I mean you would need to collect some huge number of samples e.g. $2^{128}$ and it would take longer than the lifetime of the universe and use up more energy than the suns output over its entire lifetime.
  
  > What kind of approach could be taken?
  
  None, it is impossible, and AI won't help.
  
  What if the random number generator was not so good . . .
  
  Poorly designed random number generators can be predicted. Really old ones might fall to statistical analysis, and you could even train something like an LSTM to predict the next number in the sequence. This has nothing to do with the PDF, although you will need to reverse-engineer how the PDF is being produced in order to get at the raw PRNG outputs for analysis. Also, almost no modern computer language or library uses a random number function that is so simple.
  
  For modern but insecure generators, such as the Mersenne Twister algorithm if you know or can reverse-engineer the algorithm being used, sometimes it may be possible to infer the current state of a random number generator from a certain number of samples. This is not really an AI issue though, but more closely related to cryptography. I believe the minimum number of samples to infer Mersenne Twister state is something like 640.
  
  > **Comments:**
  > **username_0**: Thank you for the response, very helpful. Now, what if we shift the goal from predicting the values, to predicting the range in which the next value will fall? Assuming we have N bins, would decreasing the size of N make the problem more "approachable" ? Or would it still be impossible? @Neil Slater  
  > **username_2**: If it's a true random number generator, then there is no way to "predict" the next number, the next bin, or next anything. By definition, if it's random there should be no information available about it until you see the number.  
  > **username_2**: However, it's rare that you *actually* have random numbers. For example, Microsoft thought [PhotoDNA](https://anishathalye.com/inverting-photodna/) hashes were random enough, until they got inverted with the help of neural networks.  
  > **username_3**: If it is enough to predict it going in a certain bin it can be feasible for pseudorandom variables. I remember having a huge excel that showed the drop rate of an item in a chest in an rpg based on what value the cure magic had in battle or something like that...  
  > **username_1**: @luk it would still be impossible. Although your accuracy would improve. E.g. if there was one bin from the pdf which contained 50% of the probability, then you could predict that the next number would be in that bin with 50% accuracy.  
  > **username_1**: @Emil: You can always predict a probability that matches the probability derived from the PDF. This is normal in machine learning, where the "residual" unknown factors impact prediction accuracy, but you can still often make predictions that are useful (effectively the ML learns the PDF, or at least the value to predict from it that leads to lowest error). It is also very different from "hacking" an underlying PRNG, which would have to be very low quality to achieve results using ML.  
  
  ---
  
  