Consider the .NET Random stream:
var r = new Random();
while (true)
{
r.Next();
}
How long does it take to repeat?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
According to the documentation:
The subtractive generator (Knuth, Vol 2)
Xf,n = (Xf,n-k – Xf,n-j) mod 1.
See Knuth for a table of possible values of k and j. We choose k = 63, j = 31. This generator is interesting because:
The second property holds when X is of the form
l 247
(0 � l < 247)
Single-precision arithmetic is exact on the Crays (48-bit mantissa) and as is double-precision arithmetic on IEEE-compliant machines.
This allows the basic random number sequence to be generated by the Fortran code
In practice random numbers are generated in batches as needed and stored in an array which acts as a circular buffer.
The algorithm mentioned has a period that depends on the seed value – you can find more details here.