POV-Ray : Newsgroups : povray.advanced-users : Normal distribution Server Time
28 Jul 2024 22:19:50 EDT (-0400)
  Normal distribution (Message 11 to 13 of 13)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Chris Johnson
Subject: Re: Normal distribution
Date: 7 May 2004 16:21:57
Message: <409befe5$1@news.povray.org>
-[Not quite correct]-
That's why I said "about 2^-52" not "2^-52". I wasn't going to go into the
details of floating point when it is rendered irrelevant by the fixed-point
form of the random number generator.

-[At most, it may be even less]-
It wouldn't be a 32-bit linear congruential generator if it didn't use
32-bits. I looked at the pov-ray source before I posted to make sure it was
a 32-bit generator, rather than the C library rand() function, which is
often only 15- or 16-bit.

-Chris


Post a reply to this message

From: Christopher James Huff
Subject: Re: Normal distribution
Date: 7 May 2004 17:31:06
Message: <cjameshuff-7537DE.16302607052004@news.povray.org>
In article <409befe5$1@news.povray.org>,
 "Chris Johnson" <chris(at)chris-j(dot)co(dot)uk> wrote:

> -[At most, it may be even less]-
> It wouldn't be a 32-bit linear congruential generator if it didn't use
> 32-bits. I looked at the pov-ray source before I posted to make sure it was
> a 32-bit generator, rather than the C library rand() function, which is
> often only 15- or 16-bit.

However, it may not be full period, meaning it may cycle through a 
subset of that range. There are various choices for the different 
coefficients that will give full period generators, and a small mistake 
in choosing them will cause the generator to only cycle through some 
numbers in the range before repeating.

POV-Ray's PRNG actually isn't a typical LCG generator. Such generators 
are of the form:
r[n] = (r[n - 1]*a + c) mod m

POV-Ray's generator lets overflow wraparound take care of the modulus, 
and then takes a subset of the bits of the resulting number for the 
result. It uses "12345" for c, which makes me think the coder didn't put 
much work into choosing the parameters. It uses a non-prime m due to the 
way it works around computing a modulus, and I'm pretty sure that alone 
makes it non-full period. Finally, and most important to this 
discussion, it does a bit shift and bitwise AND with 0x7FFF on the 
result of the LCG, and thus can not return numbers out of the range [0, 
32767].

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Andrew C on Mozilla
Subject: Re: Normal distribution
Date: 16 May 2004 14:12:38
Message: <40a7af16@news.povray.org>
> -[because the means of different samples from a given population are
> normally distributed around the true mean of the population]-
 >
> Yes - or rather, they approach a normal distribution as the number in each
> sample tends to infinity (the Central Limit Theorem)

Ah... I *knew* reading an entire book on statistics would be useful one 
day! :-)

Andrew @ home.


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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