POV-Ray : Newsgroups : povray.advanced-users : Need help with rand/seed : Re: Need help with rand/seed Server Time
2 Nov 2024 03:14:22 EDT (-0400)
  Re: Need help with rand/seed  
From: Chris Huff
Date: 13 Jul 2000 16:35:48
Message: <chrishuff-ABCB65.15361113072000@news.povray.org>
In article <01bfed07$27644560$1a1ba1d0@mk>, "CreeD" <meshe@nqi.net> 
wrote:

> You're probably right, but really, if you can be EXACTLY as clear with
> fewer and easier words, why wouldn't you? You make it sound like this was
> written by programmers, for programmers. It's not. I should be able to
> learn with 0 previous programming experience from the windows help file.  

Actually, this keyword is something called a "function". It is a 
programming feature, so it is quite logical to use programming 
terminology to describe it. It "returns" a value, meaning, the name of 
the rand function followed by a random number stream is the same as the 
next pseudo-random number from that stream. It can *not* be described as 
precisely with fewer and more common words, the special terminology is 
used to convey the exact meaning. If you refuse to learn the 
terminology, don't complain about not being able to understand it. Doing 
so is like insisting that everyone use your native language, no matter 
how awkward it makes things.


> So anyway.  RantRant.  Why do the randomized X points in my SOR shift 
> back and forth irregularly, but never seem to leave a certain 
> boundary no matter what kind of number I plug in after seed()?

Because the rand() function always returns a value between 0 and 1. The 
seed value is irrelevant, it only specifies the stream of numbers, and 
does not affect the range.

The numbers are not truely random, they are "pseudo random". This means 
that given the same starting conditions, rand() will always produce the 
same sequence of numbers. This sequence of numbers is called a "stream", 
and is initialized by the "seed()" function, which returns the stream. A 
stream produced by calling seed() with a certain number will always 
produce the same sequence of pseudo-random numbers.
The rand() function always returns values in the range 0-1. Always. The 
seed for the stream passed to it has no effect on this, changing it will 
only give a different sequence of pseudo random numbers.

Your points shift back and forth irregularly because they depend on the 
value returned by rand(). They never leave a certain range because 
rand() never leaves a certain range. The number you plug into seed() 
doesn't affect this range, because it is not supposed to.

-- 
Christopher James Huff - Personal e-mail: chr### [at] maccom
TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
Personal Web page: http://homepage.mac.com/chrishuff/
TAG Web page: http://tag.povray.org/


Post a reply to this message

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