POV-Ray : Newsgroups : povray.binaries.images : Toward a less-lame rand() function. : Re: Toward a less-lame rand() function. Server Time
1 Aug 2024 00:16:12 EDT (-0400)
  Re: Toward a less-lame rand() function.  
From: clipka
Date: 20 May 2009 11:15:01
Message: <web.4a141dd82a89ae6df708085d0@news.povray.org>
"Kenneth" <kdw### [at] earthlinknet> wrote:
> Interesting! So as I understand it--again using seed(23) and seed(24) as
> examples--the '23' and the '24' are definitely not next to each other in the
> 2^32 stream, but are distributed *who knows where* (admittedly a simplified way
> of expressing the situation.) Correct so far?

Definitely so.

> Then (guessing further), the rand() calls from those two seeds 'start up' at the
> pseudo-random values following the pseudo-randomly-dispersed 23 and 24 in the
> stream? (I may be *grossly* oversimplifying here.)

You're not oversimplifying more than I did, so yes :)

> If my simplistic assumptions/understandings are correct, then it seems to me
> that it all still begs the question of why there are repetitive patterns when
> using seed(frame_number) in animations--albeit when calling only one rand()
> value per seed. I don't mean to beat this poor old horse to death, but
> seed(frame number 23) and seed(frame number 24) should--as far as I understand
> things--pick up the 2^32 stream at wildly differing locations (with completely
> different 'blocks' of random values that rand() then picks out--even just one
> rand() call.) If the 2^32 values in the stream are indeed pseudo-randomly
> created, then from where does a semi-repeating pattern arise?

I'm a bit puzzled about this one as well. I guess I'll have to look at the
actual code one of these days. It *may* be the case that the first rand()
actually does not yet pull the value *after* the "23", but the "23" itself -
somewhat garbled due to the hashing always performed, but still with a
recognizable correlation to the seed value.

It might be interesting to see how the "single-rand()-per-frame" thing works out
when you discard the first result of rand(), and use only the second result,
e.g.:

#declare R = seed(4711);
#declare dummy = rand(R);
#declare myValue = rand(R);


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.