http://qs321.pair.com?node_id=175680


in reply to is rand() random

rand() uses (IIRC) the built-in rand() function on your platform. This is a pseudo-random number generator, not true random numbers. Perhaps the rand() function is not up to snuff on your OS.

BTW, random doesn't neccessarily mean no duplicates. The sequence 5 5 5 5 5 is just as likely as the sequence 3 2 4 1 5 or 1 2 3 4 5. It just doesn't look random to us humans, who are wired for pattern recognition.

Replies are listed 'Best First'.
Re(2): is rand() random
by FoxtrotUniform (Prior) on Jun 19, 2002 at 15:36 UTC
      rand() uses (IIRC) the built-in rand() function on your platform.

    More to the point, stdlib rand() functions tend to be abysmally poor at generating even remotely random numbers (for both statistical and cryptographic definitions of "random"). Math::Random and Math::TrulyRandom are both good places to look for randomness in Perl, but coding up your own PRNG isn't terribly taxing, and a lot of fun.

    --
    The hell with paco, vote for Erudil!
    :wq