POV-Ray : Newsgroups : povray.documentation.inbuilt : (seed) could use a better explanation Server Time
29 Mar 2024 01:29:35 EDT (-0400)
  (seed) could use a better explanation (Message 7 to 16 of 16)  
<<< Previous 6 Messages Goto Initial 10 Messages
From: Warp
Subject: Re: (seed) could use a better explanation
Date: 8 Oct 2005 01:36:18
Message: <43475ad2@news.povray.org>
Kenneth <kdw### [at] earthlinknet> wrote:
> Let's see if I can phrase this correctly:  Say you choose SEED(432) to
> initialize your first random number process. Then the first "random" number
> that RAND chooses from that will be, let us say, .36547 (not really, that's
> just a guess.) And the next "random" number that RAND chooses will be, let
> us say, .85645.  Fine and dandy, so far. NOW, if you then, without
> thinking, choose to initialize a new SEED as SEED (433) -- i.e., only one
> integer number away from your first SEED value-- then the very first
> "random" number that this new SEED's RAND function will choose will be, lo
> and behold, .85645---the very same "random" number that the FIRST SEED's
> 2nd RAND  function returned!  Am I making sense?

  It's logical to come to that conclusion from my explanation, but it
doesn't work like that.
  You see, I said "you can think of it as an index", but it's not a
linear index. The seed value is closely related to the random number
generation itself, which means that the relation between a seed value
and the value returned by rand() is pseudorandom as well.

  Ok, I'm not even sure myself that that explanation was understanble (or
even correct, for that matter).
  What I mean is that the order in which rand() pops numbers from the list
is not the same order as seed() "indexes" that list. The "index" jumps
pseudorandomly over the "list" of numbers. This means that if you use
seed(100), pop a number with rand() and then another, that next number
might well correspond to something like what seed(5033921) will make
rand() to return at first.

  The seed value (which is a 32-bit integer) jumps pseudorandomly over
its entire value space (ie. between 0 and 2^32-1) and the value returned
by rand() is simply calculated from this seed value.
  The formula which modifies the seed value is just so incredibly ingenuous
that it will really go through all 2^32 possible values in a pseudorandom
order before starting over.

> If my thinking is correct, this is wholly different behavior than if SEED
> created completely *new and different* random number streams for each and
> every number that was placed into it.

  From the point of view of the user it is almost as good as if seed()
created completely new random streams for every different value of seed()
because there's very seldom any overlapping. In some rare cases you might
encounter that one rand() starts repeating the same values as another rand()
using a different seed, but that happens very rarely.
  After all, you have 2^32 possible start points to start from (and it's
very hard to find start points which are close together).

-- 
                                                          - Warp


Post a reply to this message

From: Kenneth
Subject: Re: (seed) could use a better explanation
Date: 10 Oct 2005 14:35:00
Message: <web.434ab1456c2f1bf952c9f5e0@news.povray.org>
> WARP wrote....

>   ...From the point of view of the user it is almost as good as if seed()
> created completely new random streams for every different value of seed()
> because there's very seldom any overlapping.
>                                                           - Warp

FASCINATING!  POV's cryptographic scheme is quite amazing. It sure does
"stir the soup" of random numbers!  THANKS for taking the time to go into
this in such detail; I've never seen it so well-explained. Bottom line:  I
no longer need to worry about the exact value placed into SEED.  Happy days!

Ken


Post a reply to this message

From: Ken Hutson
Subject: Re: (seed) could use a better explanation
Date: 10 Oct 2005 20:09:55
Message: <434b02d3@news.povray.org>
Kenneth,
There is some intresting reading on pseudo-random number generation at 
www.wikipedia.org
Kenneth Hutson


Post a reply to this message

From: Kenneth
Subject: Re: (seed) could use a better explanation
Date: 11 Oct 2005 02:50:01
Message: <web.434b5fe16c2f1bf914d4b080@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:

>   The formula which modifies the seed value is just so incredibly ingenious
> that it will really go through all 2^32 possible values in a pseudorandom
> order before starting over.
>

>                                                           - Warp

BTW, I understand now why the complex technical workings of SEED would
probably be inappropriate for inclusion in the POV docs. That's a lot of
information, most (all?) of which would be needed to do it justice. I do
think, though, that a few of the general concepts could be touched on, if
only for general interest.

The RAND and SEED definitions still seem a bit ....obtuse?...in their
present form, at least to me.  But rather than whine and complain, I think
I'll try my own hand at coming up with some meatier explanations. If  I
manage to do so, I'll post them for vetting.

Thanks again!

Ken


Post a reply to this message

From: Kenneth
Subject: Re: (seed) could use a better explanation
Date: 11 Oct 2005 02:55:00
Message: <web.434b60876c2f1bf914d4b080@news.povray.org>
"Ken Hutson" <ken### [at] goettingcom> wrote:
> Kenneth,
> There is some intresting reading on pseudo-random number generation at
> www.wikipedia.org
> Kenneth Hutson

Thanks, I'll give that a look!

Ken


Post a reply to this message

From: Kenneth
Subject: Re: (seed) could use a better explanation
Date: 11 Oct 2005 03:30:01
Message: <web.434b69046c2f1bf914d4b080@news.povray.org>
Oh...one other TINY little question, mostly out of curiosity: What is the
"length" of the integer value that can be placed into SEED?  That is, how
many digits long?  Did I overlook that in the docs somewhere? From Warp's
discussion, I *suspect* it is 32, but that's a guess. Curious minds want to
know!  ; - )

Ken


Post a reply to this message

From: Warp
Subject: Re: (seed) could use a better explanation
Date: 11 Oct 2005 04:57:26
Message: <434b7e76@news.povray.org>
Kenneth <kdw### [at] earthlinknet> wrote:
> Oh...one other TINY little question, mostly out of curiosity: What is the
> "length" of the integer value that can be placed into SEED?  That is, how
> many digits long?  Did I overlook that in the docs somewhere? From Warp's
> discussion, I *suspect* it is 32, but that's a guess. Curious minds want to
> know!  ; - )

  A 32-bit number, which can represent 2^32 different values, contains
32 *binary* digits (ie. 0 or 1).
  In decimal the maximum value of a 32-bit number is 4294967295 (10 digits).

  If you give seed() a larger number it will probably just get truncated
(IOW the number modulo 4294967296 will be used).

-- 
                                                          - Warp


Post a reply to this message

From: Kenneth
Subject: Re: (seed) could use a better explanation
Date: 11 Oct 2005 23:55:01
Message: <web.434c87f56c2f1bfd82bb7c00@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:

>   A 32-bit number, which can represent 2^32 different values, contains
> 32 *binary* digits (ie. 0 or 1).
>   In decimal the maximum value of a 32-bit number is 4294967295 (10 digits).

>                                                           - Warp

Thanks.  BTW, the clue was sitting there right in front of me, and I didn't
*see* it. Sorry.

Warp wrote...
>      The seed value (which is a 32-bit integer) jumps pseudorandomly over
>      its entire value space (ie. between 0 and 2^32-1) and the value returned
>      by rand() is simply calculated from this seed value.

Ken


Post a reply to this message

From: Kenneth
Subject: Re: (seed) could use a better explanation
Date: 27 Oct 2005 16:20:00
Message: <web.4361355d6c2f1bf71fa4210@news.povray.org>
"Kenneth" <kdw### [at] earthlinknet> wrote:
> ...I think I'll try my own hand at coming up with some meatier
> explanations. If  I manage to do so, I'll post them for vetting.
>

I hereby offer alternate wordings of POV's definitions
(hopefully more English-friendly), specifically for new users -- those who
are just coming across the definitions for the first time. Personally, I
see a need for that. I've shamelessly borrowed from all that has been
posted here, but the paraphrasing is my own, so I'm the only one to blame
if something isn't correct.
-----
SEED(I)   Works together with RAND, for the creation of random values.  From
any integer value placed into it, SEED() effectively creates a long
pseudo-random stream of individual numbers, each between 0 and 1 inclusive.
 The integer can range from 0 up to 4294967295  (i.e., 2 ^ 32 - 1.) A float
is allowed, but will be truncated to an integer.  Each and every value will
effectively produce a completely different stream.  (Though not technically
correct, the end result is practically the same.) Each subsequent call from
RAND will then "withdraw" a different value from this stream.  SEED (I)
must first be initialized (#declared) as a variable before RAND can call on
it. Any number of streams can be initialized in your scene's code.

RAND(V)  Works together with SEED. Each time RAND() is called -- using
SEED's #declared variable name -- a pseudo-random float value is
"withdrawn" from the SEED stream, in the range of 0 to 1 inclusive. This
process is itself psuedo-random; each RAND() call will "jump" all over the
entire stream to choose a value. The two working together produce a good
approximation of randomness.  This random number creation is independent of
the computer platform or OS; for any integer placed into SEED(), the exact
same stream -- as well as its RAND() value(s) -- will be returned,
regardless of computer platform. This allows scene files to be rendered
identically on different platforms.

-------
Perhaps a bit wordy, but,...is this more clear? Less clear? The same?

I invite comments, criticisms, additions or further clarifications.

Ken


Post a reply to this message

From: Warp
Subject: Re: (seed) could use a better explanation
Date: 28 Oct 2005 10:30:19
Message: <436235fb@news.povray.org>
Kenneth <kdw### [at] earthlinknet> wrote:
> for any integer placed into SEED()

  That expression is somewhat incorrect because you do not place anything
into SEED().
  seed() is just a function which returns a seed value (which is calculated
from the parameter given to it). This seed value can then be given
(repeatedly) to the rand() function.

  Seed values are independent in that they do not interfere with each
other (which is a rather handy feature).

-- 
                                                          - Warp


Post a reply to this message

<<< Previous 6 Messages Goto Initial 10 Messages

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