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:18:01 EDT (-0400)
  Re: Toward a less-lame rand() function.  
From: Slime
Date: 20 May 2009 02:29:49
Message: <4a13a35d$1@news.povray.org>
> 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 don't think POV-Ray's RNG does any hash with your initial value. I think 
clipka was referring to other RNGs.

LCGs, like the one POV-Ray uses, usually do a simple process with the seed 
along the lines of multiplying by a constant, adding a different constant, 
and then looping the result back around if it's too high. Every time you 
take a random number, it does this again with the previous one. When you 
always start with a similar number, this basic math doesn't provide enough 
randomness. However, you might find that you can get better results if you 
call rand() with the seed a few extra times before using it.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

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