General Information
The next 2 paragraphs are by Dr. D. E. Knuth in The Art of Computer Programming
from his introduction to the chapter on random numbers.
People who think about [random numbers] almost invariably get into philosophical
discussions about what the word “random” means. In a sense, there is no such
thing as a random number; for example, is 2 a random number? Rather we speak of
a sequence of independent random numbers with a specified distribution, and this
means loosely that each number was obtained merely by chance, having nothing to
do with other numbers in the sequence, and that each number has a specified
probability of falling in any given range of values.
There is a fairly obvious objection to [any algorithmic random number
generator.] How can a sequence generated in such a way be random, since each
number is completely determined by [the state of the generator?] The answer is
that [such a] sequence isn't random, but it appears to be. In typical
applications the actual relationship between one number and its successor has no
physical significance; hence the nonrandom character is not really undesirable.
ALL random number generators use two functions:
Seed[i] = f1(Seed[i-1])
return f2(seed[i])
Function f1(...) makes whatever randomness the generator has. It does all the
work. But function f2(...) is also important, and must not compromise the work
done by f1(...).
In the section Random Integers from Random Integers we discuss a third function that uses our returned value.
In addition, floating point results are sometimes needed. Using an unsigned
32-bit random function one could divide the result by float(2^32). For such
goodies as normally distributed random values please consult standard reference
materials. Knuth has a simple method that takes two random floating point values
and with probability pi/4 returns two normally distributed values.