Random Generators: What is a seed?

Computers can't by themselves generate truly random numbers. It's therefore common to use pseudorandom number generators.

A pseudorandom number generator generates the same number sequence over and over. It's in fact semantically equivalent to

// Seemingly random, but fixed, list of numbers
numbers ← { 8651, 1932, 18626, 77, 8524 }
while true
    for n in numbers
        print n

In reality numbers obviously corresponds to a much longer array (typically 232 numbers) and the implementation doesn't store the numbers explicitly.

The seed is simply the index at which the generator starts reading numbers.

To get truly random numbers, the computer needs some source of entropy. Examples of such sources are keyboard/mouse readings or the system clock.


Be the first to comment!