POV-Ray : Newsgroups : povray.advanced-users : Need help with rand/seed : Re: Need help with rand/seed Server Time
30 Jul 2024 00:30:28 EDT (-0400)
  Re: Need help with rand/seed  
From: Ron Parker
Date: 13 Jul 2000 16:24:06
Message: <slrn8msa7k.1p3.ron.parker@linux.parkerr.fwi.com>
On 13 Jul 2000 16:10:38 -0400, CreeD wrote:
>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 that's not what seed() does.  Seed just gives you a different 
starting point in the list of pseudorandom numbers that rand() spits out.
Rand() always *always* returns a number between 0 and 1.  How can we rewrite
the part of the documentation that says "The numbers are uniformly 
distributed, and have values between 0.0 and 1.0, inclusively" to make
this simpler?  

It seems to me that the only thing a non-programmer would have trouble 
understanding in the definitions of seed() and rand() is the notion that
a stream is the same as a generator, as used in the paragraph that states

   Multiple random generators are very useful in situations where you use 
   rand() to place a group of objects, and then decide to use rand() in 
   another location earlier in the file to set some colors or place another 
   group of objects. Without separate rand() streams, all of your objects 
   would move when you added more calls to rand(). This is very annoying. 

Here's the best I can do at explaining rand() and seed() in a way that's 
different (but not better) than that in the manual:

Seed creates a new pseudorandom number generator.  This generator will always
provide the same sequence of numbers in the same order each time you parse the
scene file.  All the seed affects is the specific sequence of numbers returned.
It does not affect their randomness, their range, or their distribution.

Rand gives you the next number from a particular generator (created by the
Seed function.)  All numbers returned are between 0 and 1.  If you want some
other range of numbers, multiply, divide, add, or subtract until the range is 
what you need.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

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