Re: [APPL:DarwinDev] Re: rand() and srand() broken?
Re: [APPL:DarwinDev] Re: rand() and srand() broken?
- Subject: Re: [APPL:DarwinDev] Re: rand() and srand() broken?
- From: "Jay A. Kreibich" <email@hidden>
- Date: Wed, 25 Nov 2009 21:11:21 -0600
On Wed, Nov 25, 2009 at 03:18:17PM -0500, Clark Cox scratched on the wall:
> On Wed, Nov 25, 2009 at 2:47 PM, Derek Gaston <email@hidden> wrote:
> > Indeed... note that this wasn't about passing the _same_ value...
> > it was about passing similar values to srand... like singularly
> > increasing integers...
> I was responding specifically to:
>
> "Are you (and everyone else that replied) trying to tell me that the
> first number out of rand() (after reseeding) should always be the
> predictable?"
You're misinterpreting the term "predictable." The OP states, in the
same post you are quoting from, that they know the first number out
is always the same for a given seed. In fact, their application design
depends on it. This quote doesn't say, "for a specific seed value."
Their point was that if you know the first number out for a given
seed, you can predict-- with a fairly high degree of accuracy-- what
the first number out will be for a very similar (numerically close)
seeds. In other words, there is a highly structured relation between
the seed value and the first value out, making it easy to accurately
estimate-- i.e. predict-- what the first value out will be for seed
values we haven't tested yet.
To put it yet another way, if you know the first value from srand(N)
and srand(N+2), you can make a good prediction of the first value
from srand(N+1) for any value of N. This makes the first value out
predictable, not in terms of a specific N, but as a general property
of the PRNG.
That's clearly a poor property for a PRNG, just as it would be for a
hash.
-j
--
Jay A. Kreibich < J A Y @ K R E I B I.C H >
"Our opponent is an alien starship packed with atomic bombs. We have
a protractor." "I'll go home and see if I can scrounge up a ruler
and a piece of string." --from Anathem by Neal Stephenson
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden