|
|
On 2001-02-09 04:09, Ron Parker <ron### [at] povrayorg> wrote:
>On 7 Feb 2001 21:49:22 -0500, Pete wrote:
>Nope, the generator is the one I posted. Nothing fractal about it. It's
>just not a very good generator. The numbers (or at least the 12345)
>look just a little arbitrary.
The example in the C standard also uses 12345 as the offset, but a
different multiplicator. Basically, for this kind of RNG, the three
numbers (the multiplicator, the offset and the modulus), must have a
GCD of 1[1], which is true for 1812433253 = 1289 * 1406077, 12345 = 3 *
5 * 823 and 4294967296 = 2 ^ 32). Then the sequence will produce all
non-negative numbers less than the modulus. Of course, some sequences
look more random than others ...
One problem with this type of RNG is than it produces "subsequences"
for each divisor of the modulus. For a modulus which is a power of two
this is particularly annoying since the lowest bit will run through a
sequence of two, the lowest two bits through a sequence of four etc.
Thus, to get random results, you should always take the highest bits,
not the lowest. Unlike C, Povray makes this "natural", by converting the
value to a double of range [0...1).
hp
[1] My memory is a bit fuzzy here - correct me, if I'm wrong.
--
_ | Peter J. Holzer | All Linux applications run on Solaris,
|_|_) | Sysadmin WSR | which is our implementation of Linux.
| | | hjp### [at] wsracat |
__/ | http://www.hjp.at/ | -- Scott McNealy, Dec. 2000
Post a reply to this message
|
|