POV-Ray : Newsgroups : povray.general : rand question : Re: rand question Server Time
5 Aug 2024 02:23:38 EDT (-0400)
  Re: rand question  
From: Micha Riser
Date: 12 Feb 2003 10:06:09
Message: <3e4a62e1@news.povray.org>
Warp wrote:

> Tom Melly <tom### [at] tomandlucouk> wrote:
>> Once I'd worked out what the code did, the same thought occured - is
>> there something in the way the stream is generated that makes that
>> impossible? For example, that a particular number is always followed by
>> another fixed number?
> 
<snip>
>   As I don't have any idea what kind of algorithm pov's generator uses,
> I can't say how it works there. Very simple generators start repeating
> over immediately when the same number which has appeared before appears
> again.
> 

I found following in POV's express.cpp

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

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

An iterated random generator like this obiously cannot have a longer period 
than 2^sizeof(int).

- Micha

-- 
POV-Ray Objects Collection: http://objects.povworld.org


Post a reply to this message

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