POV-Ray : Newsgroups : povray.general : problem: repeating rand patterns using seed in animation : Re: problem: repeating rand patterns using seed in animation Server Time
30 Jul 2024 20:20:16 EDT (-0400)
  Re: problem: repeating rand patterns using seed in animation  
From: Nicolas George
Date: 25 Jan 2009 03:48:27
Message: <497c275b$1@news.povray.org>
"Kenneth"  wrote in message
<web.497c1bf0b528db0df50167bc0@news.povray.org>:
> I'm not sure I really understand that whole concept. (Long ago, Warp helped me
> out with a detailed discussion of the finer points of rand and seed; I need to
> revisit that post for a 'refresher course'.)

Pseudo-random generators work with a sequence (in the mathematical sense, in
practice, they only keep one term in memory) of state values defined like
this:

	s_0 = seed
	s_(n+1) = m( s_n )

where m is a function that blends and mixes the input. The resulting random
numbers are:

	r_n = e( s_n )

The e function extracts the random value from the state. For example, the
s_n sequence could be a 128-bits number (or a 16-octets array), m would do
various binary and arithmetic permutations, and e would extract the middle
16-bits of the number.

The strength of a PRNG is in the s function. If you use only the first term,
then you get only the e function:

	r_0 = e( s_0 ) = e(seed)

and the e function is not designed to create pseudo-randomness.

The standard solution to this problem is to drop the recursive sequence
scheme and go for a random function. For example:

	r_n = lower_16_bits( SHA1( concat(seed, n) ) )


Post a reply to this message

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