POV-Ray : Newsgroups : povray.documentation.inbuilt : revisiting rand(...) : Re: revisiting rand(...) Server Time
18 Apr 2024 13:33:16 EDT (-0400)
  Re: revisiting rand(...)  
From: clipka
Date: 17 Jul 2018 13:45:22
Message: <5b4e2b32$1@news.povray.org>
Am 17.07.2018 um 12:27 schrieb Kenneth:
> I'm wondering about the documentation for rand(...).
> 
> It has stated for a long time that the values that rand produces are "between
> 0.0 and 1.0, inclusive." But in all my uses of it in scenes, the value never
> actually hits those exact values. (Some of my code would actually have a problem
> if that happened; but I've never encountered such a problem... which is why I
> now ignore the 'inclusivity.')
> 
> On a whim, I ran some tests (with different seed(...) values)-- 10,000,000 tries
> each time. But I haven't yet seen a 1.0 or a 0.0 occur.

Theoretically and without too detailed analysis(*), the random number
generator should be able to generate 2^32 (approx. 4 [short] billion)
different results, including both 0.0 and 1.0. So unless you did your
experiment with 200 different seeds, you're still far from the threshold
where you could expect /any/ particular result value crop up for sure.

(*The floating-point random number generator is based on an integer
Linear Congruential Generator; there is some chance the configuration
parameters of that LCG cause it to disfavour result values 0.0 and/or
1.0. However, without detailed analysis, the same could be said for any
other of the 2^32 possible result values.)


Post a reply to this message

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