There's more than one way to do things | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
This is because rand() is not really producing a random (as in throwing a dice) number. What rand() does, is calculate a value using a function with many arguments taken from your computer...
Those arguments are there to increase the level of entropy. This makes the result of the function look as if it were indeed random, because you have very little control over the variables that are used by the rand() function. Whenever you reset the random seed with srand(), you're placing the generator in a state which might be too close to an earlier state. Since the time displacement between the two events can be very small, because the speed of your computer is comparatively high, the rest of the variables used by the random number generator might have the same (or very similar) values, so the rand() function will repeat an earlier sequence of numbers.
In reply to Re: Re: srand and seed
by fokat
|
|