|
![](/i/fill.gif) |
>>>How many numbers are in the rand stream before it repeats itself
>
>>4.29 billion (2^32, to be exact).
>
> Do you have any concrete proof or demonstration of this?
There is such proof. From the source (texture.cpp, don't know why there):
static unsigned long int next_rand = 1;
int POV_RAND()
{
next_rand = next_rand * 1812433253L + 12345L;
return((int)(next_rand >> 16) & RNDMASK);
}
I turned this into a program for testing the period as follows:
#include <iostream.h>
void main() {
static unsigned long int next_rand = 1;
static unsigned long int count = 0;
do {
next_rand = next_rand * 1812433253L + 12345L;
count++;
} while (next_rand!=1);
cout << count;
}
which returned 0. Now if you think this over, that means that it
is a full period generator.
--
max_trace_level 256media{absorption.02}camera{location<1,.3,1.7>}sphere{0
.8pigment{color.6}interior{media{emission<2,2,-2>absorption 2}}hollow}#macro
p(f,n)plane{n f-1finish{reflection<f,1f>}}#end p(1y)p(1z-x)p(-1,-z)p(1x-y)
// Mark Weyer
Post a reply to this message
|
![](/i/fill.gif) |