You probably want to read (and understand) Prelude's page too - that is, if you care about the distribution of your random numbers. [And if you REALLY want good random numbers, don't use rand - as it's by no means guaranteed to be "good"].

--
Mats

10-14-2007

Yarin

I did read it quite a while ago, but I figured out that rand() was producing pretty much the same thing as her version of rand(). All I have to do is call srand() every 1k calls to rand().

10-14-2007

matsp

Quote:

Originally Posted by Yarin

I did read it quite a while ago, but I figured out that rand() was producing pretty much the same thing as her version of rand(). All I have to do is call srand() every 1k calls to rand().

Calling srand again after calling it the first time will NOT improve the distribution of your sequence - it will restart the sequence with a different seed, and depending on the seed value, it may give you the same sequence as last time or a different sequence. But it won't make the distribution any better.