Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a seed in relation to a random number generation algorithm and why is computer time used to create this seed more often than not?

I read that seeds are used to initialize random number generators. But seems like the randomness of the seed doesn't matter much for getting good randomness from the generator. So I want to understand what is a seed actually? Why is it called so? And lastly why time in a computer system is used to generate such seeds?

like image 284
Geek Avatar asked Mar 13 '13 14:03

Geek


1 Answers

A pseudo-random number generator produces a sequence of numbers. It isn't truly random, but generally a mathematical calculation which produces an output that matches some desirable distribution, and without obvious patterns. In order to produce such a sequence, there must be state stored for the generator to be able to generate the next number in that sequence. The state is updated each time using some part of the output from the previous step.

Seeding explicitly initialises this state. A 'seed' is a starting point, from which something grows. In this case, a sequence of numbers.

This can be used either to always generate the same sequence (by using a known constant seed), which is useful for having deterministic behaviour. This is good for debugging, for some network applications, cryptography, etc.

Or, in situations where you want the behaviour to be unpredictable (always different each time you run a program, a card game perhaps), you can seed with a number likely to be continually changing, such as time.

The 'randomness' of the sequence does not depend on the seed chosen, though it does depend on not reseeding the sequence.

like image 69
JasonD Avatar answered Nov 02 '22 20:11

JasonD