POV-Ray : Newsgroups : povray.advanced-users : Random variation Server Time
1 Nov 2024 07:25:36 EDT (-0400)
  Random variation (Message 1 to 10 of 25)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Andrew Coppin
Subject: Random variation
Date: 26 Sep 2002 09:48:42
Message: <3d93103a@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I was doing a render earlier today, and I got to wondering about
something... Suppose you write something like

#declare A = seed(...);
#declare J = rand(A);
#declare K = rand(A);

POV-Ray's rand() function returns random numbers in the (closed?)
invertal 0..1. But what is the minimum difference between J and K?
Presumably if you're really fluky they might just happen to have the
exact same value (improbable but not impossible). Assuming this is
not the case, what is the smallest amount they can differ by?
Specifically, I presume that POV-Ray does its calculations using some
finite level of precition. Is the minimum difference in random
answers equal to the minimum possible difference at this precition,
or is it larger? (If that makes sense!)

It's not earth-shatteringly important for me to find out the answer,
I'm just curiose ;-)

Andrew.

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPZL+L7EpzUF0Y1JeEQJk9QCdHbkAT020LB8gUwh8tEkA1ozXSegAoP5A
lbC5fJdNcH7QKG49lTvBdRmg
=aG6m
-----END PGP SIGNATURE-----


Post a reply to this message

From: hughes, b 
Subject: Re: Random variation
Date: 26 Sep 2002 10:41:45
Message: <3d931ca9$1@news.povray.org>
You can, of course, test against equality if you wanted to prevent that.
Simply by doing #if (J!=K) /* do whatever */ #end

I don't know the exact method used for a random number in POV without trying
to look it up but I'd guess its precision is the same as for any of the
math, meaning it is probably random down to the same decimal levels of other
numbers.

Just checked here using (no camera of light needed):

#declare S=seed(1234);
#declare R=rand(S);
#text {ttf "times.ttf",str(R,0,18),0.1,0
translate <-5,-0.25,10>
pigment {rgb 9}}

And this seems to get to 17 decimal places, rest are zeroes. If you use the
system specific way, -1 instead of 18 in the str(), you'll probably see it
to only 6 decimals. So it depends a lot on how you use it. 17 decimal places
leaves very little room for chance of getting two identical random numbers,
if it does indeed remain randomized over time.

This isn't the same reasoning for the seed(), it allows for the same
generation of a sequence of random numbers or else you wouldn't get
identical scenes each render.

--
Farewell,
Bob

"Andrew Coppin" <orp### [at] btinternetcom> wrote in message
news:3d93103a@news.povray.org...
>
> #declare A = seed(...);
> #declare J = rand(A);
> #declare K = rand(A);
>
> POV-Ray's rand() function returns random numbers in the (closed?)
> invertal 0..1. But what is the minimum difference between J and K?
> Presumably if you're really fluky they might just happen to have the
> exact same value (improbable but not impossible). Assuming this is
> not the case, what is the smallest amount they can differ by?


Post a reply to this message

From: Christopher James Huff
Subject: Re: Random variation
Date: 26 Sep 2002 11:50:23
Message: <chrishuff-102171.11474926092002@netplex.aussie.org>
In article <3d93103a@news.povray.org>,
 "Andrew Coppin" <orp### [at] btinternetcom> wrote:

> It's not earth-shatteringly important for me to find out the answer,
> I'm just curiose ;-)

Hmm, that's a good question...true "random" numbers would have a minimum 
difference of 0. Given the finite number of values of computer math, it 
would have a small but finite probability of happening to consecutive 
values. However, it might be impossible for the algorithm POV uses to 
generate identical consecutive values...
As a wild guess, I'd say the minimum difference without being identical 
between any two values (not just consecutive values) would be 1/(~2 or 4 
billion), depending on whether POV uses a signed or unsigned long scaled 
down to a double in the [0, 1] range. In other words, too small to worry 
about if you are concerned about any kind of "stepping".

-- 
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 Coppin
Subject: Re: Random variation
Date: 26 Sep 2002 12:05:36
Message: <3d933050@news.povray.org>
Thanks guys. Wasn't "worried" - just curiouse ;-)

Andrew.


Post a reply to this message

From: Christoph Hormann
Subject: Re: Random variation
Date: 26 Sep 2002 12:15:28
Message: <3D93329F.A5E1E5C4@gmx.de>
Christopher James Huff wrote:
> 
> Hmm, that's a good question...true "random" numbers would have a minimum
> difference of 0. Given the finite number of values of computer math, it
> would have a small but finite probability of happening to consecutive
> values. However, it might be impossible for the algorithm POV uses to
> generate identical consecutive values...
> [...]

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?

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

Of course this does not change anything about the POV-Ray random number
generator having it's limitations.

Christoph

-- 
POV-Ray tutorials, IsoWood include,                 
TransSkin and more: http://www.tu-bs.de/~y0013390/  
Last updated 13 Aug. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Christopher James Huff
Subject: Re: Random variation
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

From: Christoph Hormann
Subject: Re: Random variation
Date: 26 Sep 2002 15:30:22
Message: <3D93604D.4292E793@gmx.de>
Christopher James Huff wrote:
> 
> > 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.
> 
> [...]

All right, but mathematics don't care about double precision so since
there is an infinite number of real numbers between 0 and 1...

Christoph

-- 
POV-Ray tutorials, IsoWood include,                 
TransSkin and more: http://www.tu-bs.de/~y0013390/  
Last updated 13 Aug. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Shay
Subject: Re: Random variation
Date: 26 Sep 2002 15:32:23
Message: <3d9360c7$1@news.povray.org>
Christopher James Huff <chr### [at] maccom> wrote in message
news:chr### [at] netplexaussieorg...
>
> 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?
>

Really one die thrown twice might be a better example. Otherwise 4:1 would
be considered along with 1:4.

 -Shay


Post a reply to this message

From: Shay
Subject: Re: Random variation
Date: 26 Sep 2002 15:43:49
Message: <3d936375$1@news.povray.org>
Christoph Hormann <chr### [at] gmxde> wrote in message
news:3D93604D.4292E793@gmx.de...
>
> All right, but mathematics don't care about double precision so since
> there is an infinite number of real numbers between 0 and 1...
>

Would this matter? The second hand of a clock points in an infinite number
of directions, but also moves in infinitely small increments, so at some
point each minute the second hand is pointing exactly at the center of the
12 on the clock. It spends as much time in this position as in every other
(infinite) position on the clock.

 -Shay


Post a reply to this message

From: Christoph Hormann
Subject: Re: Random variation
Date: 26 Sep 2002 15:55:39
Message: <3D93663B.471DD47E@gmx.de>
Shay wrote:
> 
> > All right, but mathematics don't care about double precision so since
> > there is an infinite number of real numbers between 0 and 1...
> >
> 
> Would this matter? [...]

Yes, this means the chance that two consecutive random numbers have
exactly the same value is infinitely small.

Christoph

-- 
POV-Ray tutorials, IsoWood include,                 
TransSkin and more: http://www.tu-bs.de/~y0013390/  
Last updated 13 Aug. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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