POV-Ray : Newsgroups : povray.advanced-users : Random number generator needed ! Server Time
30 Jul 2024 04:19:36 EDT (-0400)
  Random number generator needed ! (Message 41 to 41 of 41)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Ron Parker
Subject: Re: Random number generator needed !
Date: 26 Feb 2001 09:45:02
Message: <slrn99kqvf.tal.ron.parker@fwi.com>
On Mon, 26 Feb 2001 15:24:26 +0100, Wlodzimierz ABX Skiba wrote:
>Ron Parker wrote in message ...
>> On Mon, 26 Feb 2001 10:47:48 +0100, Wlodzimierz ABX Skiba wrote:
>> >#warning concat(str(seed(1),0,0),"\n")
>> >#warning concat(str(seed(1),0,0),"\n")
>> >#warning concat(str(seed(1),0,0),"\n")
>> >#warning concat(str(seed(1),0,0),"\n")
>>
>> This is meaningless, as the output of the seed function is not a number.
>> It's a random number stream.
>
>
>I know
>I just answered why proposed usage: rand(seed(I1*I2))
>returns different values for the same arguments

But it doesn't.  My point was that just printing the result of the seed
function is meaningless, as it is merely an index into an array of RNG
streams.  The only thing that result is good for is for feeding into the
rand function.  You should find, though, that rand(seed(1)) always returns
the same result.

Note that using rand(seed(foo)) to generate hashes gives poor performance,
as POV will track each stream separately.  So, if you call rand(seed(foo))
1000000 times, POV will allocate enough memory to track 1000000 streams.  If
what one wants is a hash, one really should implement a hash.  Of course,
that's not easy, because there are no bitwise operators, but something 
like

#macro hash(t1,t2)
  #local p1=log(t1);
  #local p2=cos(t2);
  #local p3=sin(1e6*p2-1e2*int(1e4*p2)+1e6*p1-1e2*int(1e4*p1));
  (1e4*p3-int(1e4*p3))
#end

might work in a pinch, though the distribution may not be entirely uniform.
The principle in operation here, which might not be entirely valid, is that
the less significant digits of transcendental numbers tend to be pretty
random.  There is some correlation, but it should be at a scale far below
the integer arguments we've been talking about.

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


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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