Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Feb 2003 05:59:45 -0800
From:      David Schultz <dschultz@uclink.Berkeley.EDU>
To:        Thomas David Rivers <rivers@dignus.com>
Cc:        ache@nagual.pp.ru, kris@obsecurity.org, current@FreeBSD.ORG
Subject:   Re: Final fix for correlation problem (was Re: rand() is broken)
Message-ID:  <20030203135945.GB985@HAL9000.homeunix.com>
In-Reply-To: <200302031201.h13C1oE03172@lakes.dignus.com>
References:  <20030203114629.GA77557@nagual.pp.ru> <200302031201.h13C1oE03172@lakes.dignus.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Thus spake Thomas David Rivers <rivers@dignus.com>:
> I'm afraid I don't understand the fix... and how it
> seems to affect the historical behaviour of srand()/rand().
> 
> How does it address the understanding that if I use
> srand(28), I will get exactly the same sequence of
> numbers srand(28) produced yesterday, last week, 
> last year?
> 
> I have worked with programs that depend on exactly
> that behavior.
> 
> That is,  given the same input seed - I expect
> to see the same "random" sequence again.  
> 
> This requirement would seem to indicate that changing
> srand()/rand() isn't really possible...  And, also,
> I believe, why random() was introduced...
> 
> Please, oh please, don't change that behavior in 
> srand()/rand().

There are two sides to this argument.  One side says that rand()
should always produce the same sequence for a given seed no matter
what.  This argument is bogus, because if you need exact
reproducability across all platforms for all time, you should be
using your own PRNG.

The other side says that rand() should be a reasonably good RNG
for most applications.  It would be nice if things worked out that
way, but there are enough broken rand() implementations out there
that most people don't rely upon them.  So I'd be inclined to call
this argument bogus as well, except that I know someone who has
been burned by a bad rand() while trying to test a randomized
graph algorithm in C.

My final thoughts are that having a better rand() implementation
is a Good Thing, but it isn't that big a deal, and it certainly
isn't worth all of this bickering.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030203135945.GB985>