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:55 EDT (-0400)
  Re: Toward a less-lame rand() function.  
From: Warp
Date: 17 May 2009 04:14:50
Message: <4a0fc77a@news.povray.org>
Larry Hudson wrote:
> The key to using a RNG is that it should be seeded once and ONLY once,
> before the RNG is used the first time.  That starts up a sequence of
> random numbers.  Then each time the RNG is called it gives you the next
> (pseudo) random number in the sequence.

  That won't help the regular patterns which appear in some situations
when using a LCG (which is a very poor-quality RNG). When or how often
you seed is not really the point.

> Now, this can be a problem in POV-Ray animations because each frame is
> essentially created from scratch.  There's no built-in way to continue
> the RNG sequence between frames.

  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.

  You are confusing "seed every time before calling rand()" with "seed
at the beginning of each frame" (using a value which varies at each
frame, eg. the frame number), which are completely different things. The
former is a bad idea, the latter is completely ok and won't result in
reduction of the quality of the randomness.

  Btw, I have suggested to the pov-team the implementation of
additional, higher-quality RNGs into povray, and they liked the idea. So
it may be possible that in a future beta we might have alternative,
better-quality RNGs (the current one will obviously be preserved for
backwards compatibility reasons; the new one can be used optionally). I
can't promise anything, though.


Post a reply to this message

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