POV-Ray : Newsgroups : povray.binaries.images : Toward a less-lame rand() function. : Re: Toward a less-lame rand() function. Server Time
31 Jul 2024 18:14:57 EDT (-0400)
  Re: Toward a less-lame rand() function.  
From: Warp
Date: 17 May 2009 10:32:25
Message: <4a101ff9$1@news.povray.org>
gregjohn wrote:
> Warp <war### [at] tagpovrayorg> wrote:
>>   seed(frame_number) is a perfectly good way of using different random
>> streams at each frame. The quality of the randomness will neither
>> increase nor decrease by doing that. There will be no obvious pattern
>> caused by doing this.
>>
> 
> Unless I misunderstand what you're saying, I believe the exact opposite. I first
> discovered the problem when using seed(frame_number) and saw a predictable,
> linearly monotonous effect in rand().  I believe that's also exactly what I
> showed in my red dot pattern.  The "n" is a placeholder for what you see across
> multiple frame_number 's .

  If you are getting a regular pattern inside one single frame, it's
certainly *not* because you did a "seed(frame_number)" at the beginning
of your scene.

  "seed(frame_number)" is not any more likely to produce regular
patterns than "seed(0)" (or any other value for that matter) is.

  The only difference between doing a "seed(0)" and a
"seed(frame_number)" is that in the former case you will always get the
same sequence of numbers for the frame, while in the latter case you
will get a different sequence for each frame (which is what you usually
want). The quality of the sequence will be the same in either case.

  It has been suggested that to get a different sequence of random
numbers for each frame in an animation, some kind of "seed" value should
be saved to a file and then in the next frame read and used as parameter
for seed(). However, this does not produce anything that the simple
"seed(frame_number)" wouldn't. It will not increase the quality of the
randomness, nor reduce the likelihood of regular patterns appearing in
certain situations.

  There's one situation where doing a "seed(frame_number)" might produce
"more" regular patterns than something else, and that's if the next
frame somehow remembers what was created in the previous frame. The
simplest case is that each frame executes a "seed(frame_number)", then
calls rand() once (or to create one object), and then the location of
this object is somehow stored in a file and read in the next frame.

  In this case the effect will be the same as if you had called
seed+rand repeatedly in a loop (giving seed() the loop counter).


Post a reply to this message

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