POV-Ray : Newsgroups : povray.advanced-users : Random variation : Re: Random variation Server Time
29 Jul 2024 08:22:29 EDT (-0400)
  Re: Random variation  
From: Christopher James Huff
Date: 26 Sep 2002 14:59:00
Message: <chrishuff-DAA116.14561326092002@netplex.aussie.org>
In article <3D93329F.A5E1E5C4@gmx.de>,
 Christoph Hormann <chr### [at] gmxde> wrote:

> Hmm, i'm not sure.  If it is possible that two consecutive occur in a
> sequence of random numbers what is the probability of this event?

Ideally, just as likely as any other single combination. That is, not 
very likely with this large of a large set of possible combinations.
Say you have 2 (identical) dice. Is the 1:1 combination less likely than 
the 1:4 combination?


> In fact i don't even know if mathematics deal with something like non
> integer random numbers.

It does, it doesn't matter if it is integer or not, as long as it is a 
set of specific values. There is a finite number of values that can be 
represented with a double precision variable, with a perfect random 
number generator any one of those values would be equally likely, 
whether or not it had just come up the previous time. Assuming the 
values are evenly spaced, that is...I think. It depends on how you look 
at it and what exactly you want, I guess.

Ok, IANAM (I Am Not A Mathematician), and have never taken a statistics 
or set theory course, but:
Picking a random value from a finite set, each value has an equal chance 
of coming up, even if it was the previous value.

A perfect random number generator would produce a flat distribution, any 
range of resulting values would on average be hit the same number of 
times as any other range of equal length. You will get the same number 
of values in the range [0, 0.1] as in [0.5, 0.6] and [0.9, 1]. (on 
average of course)

I do not think all possible values a double can hold in the [0, 1] range 
are evenly distributed...it is probably close enough though. If the 
distribution is off, say there are twice as many values in the lower 
half of the range then in the upper half, a specific value in the lower 
half will have to be less likely than a specific value in the upper half 
if you want to keep a flat distribution. However, POV creates a 
pseudo-random integer value and scales it down to the right range, so 
they are evenly spaced as well as a double value can approximate and the 
generator can generate.

BTW, the algorithm POV uses to compute the next random number is:
  next_rand[stream] = next_rand[stream] * 1812433253L + 12345L;
  return((DBL)(next_rand[stream] & 0xFFFFFFFFUL) / 0xFFFFFFFFUL);

The seed() function sets the initial value of next_rand and returns the 
stream index.

-- 
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

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