POV-Ray : Newsgroups : povray.general : random numbers Server Time
8 Aug 2024 18:13:51 EDT (-0400)
  random numbers (Message 1 to 4 of 4)  
From: Pascal Baillehache
Subject: random numbers
Date: 5 Oct 2000 09:38:47
Message: <39dc8467@news.povray.org>
Hi all
what I need is the exact algorithm used in the POV rand() function, where
can I found this ?
thanks in advance
baillp


Post a reply to this message

From: Ron Parker
Subject: Re: random numbers
Date: 5 Oct 2000 09:44:59
Message: <slrn8tp1f2.k3i.ron.parker@fwi.com>
On Thu, 5 Oct 2000 15:43:18 +0200, Pascal Baillehache wrote:
>Hi all
>what I need is the exact algorithm used in the POV rand() function, where
>can I found this ?

In the source code.  Specifically, the function stream_rand() in express.c.
It's short, so I'll quote it here.  Note that it isn't the best prng in the
world, and it probably fails whole truckloads of tests for randomness, but
remember that it was added almost as an afterthought to 3.0 and hasn't been
thought of much since then.  Anyway, here ya go:

static DBL stream_rand(int stream)
{
  next_rand[stream] = next_rand[stream] * 1812433253L + 12345L;

  return((DBL)(next_rand[stream] & 0xFFFFFFFFUL) / 0xFFFFFFFFUL);
}


-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.
Proudly not helping RIAA and SDMI steal my rights -- 
  http://www.eff.org/Misc/EFF/Newsletters/EFFector/HTML/effect13.08.html


Post a reply to this message

From: Warp
Subject: Re: random numbers
Date: 5 Oct 2000 09:48:57
Message: <39dc86c8@news.povray.org>
Pascal Baillehache <bai### [at] freefr> wrote:
: what I need is the exact algorithm used in the POV rand() function, where
: can I found this ?

  In the povray source code perhaps?

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Pascal Baillehache
Subject: Re: random numbers
Date: 5 Oct 2000 15:56:00
Message: <39dcdcd0$1@news.povray.org>
Many thanks,
it doesn't matter it's not the best one, I just need to compute exactly the
same one in a C++ code for a test ...
Baillp


slr### [at] fwicom...
> On Thu, 5 Oct 2000 15:43:18 +0200, Pascal Baillehache wrote:
> >Hi all
> >what I need is the exact algorithm used in the POV rand() function, where
> >can I found this ?
>
> In the source code.  Specifically, the function stream_rand() in
express.c.
> It's short, so I'll quote it here.  Note that it isn't the best prng in
the
> world, and it probably fails whole truckloads of tests for randomness, but
> remember that it was added almost as an afterthought to 3.0 and hasn't
been
> thought of much since then.  Anyway, here ya go:
>
> static DBL stream_rand(int stream)
> {
>   next_rand[stream] = next_rand[stream] * 1812433253L + 12345L;
>
>   return((DBL)(next_rand[stream] & 0xFFFFFFFFUL) / 0xFFFFFFFFUL);
> }
>
>
> --
> Ron Parker   http://www2.fwi.com/~parkerr/traces.html
> My opinions.  Mine.  Not anyone else's.
> Proudly not helping RIAA and SDMI steal my rights --
>   http://www.eff.org/Misc/EFF/Newsletters/EFFector/HTML/effect13.08.html


Post a reply to this message

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