POV-Ray : Newsgroups : povray.general : random numbers : Re: random numbers Server Time
8 Aug 2024 20:21:21 EDT (-0400)
  Re: random numbers  
From: Ron Parker
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

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