|
 |
clipka <ano### [at] anonymous org> wrote:
>
> 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.
>
I do see your point (and Alain's): Let's say I write some code where I naively
*expect* a rand() value of 0.0 or 1.0 to pop up every now and then (well, with a
1-in-4-billion chance, assuming *equal* probability.) But those are distinct,
specific values-- it would be like expecting the exact value of .4729418830...
to pop up now and again. Which is highly unlikely (but still possible.)
But there's a practical aspect to consider, when writing a typical scene using
rand()-- if my own experience is any indication:
Let's say I want to make 10,000,000 stars in the sky. My own current way of
doing this (simplified) would be...
union{
#for(i,1,10000000)
sphere{0,1 scale 100*rand(R)
translate ...
}
#end
texture{...}
}
.... and I would ignore the *remote* possibility of rand() being 0.0, and thus
scale being <0.0,0.0,0.0>, which would trigger an error. Yet this *seems* to be
the behavior of rand(), in a practical sense, so I always feel safe in ignoring
that possibility.
But to be extra-safe, the code *should* be something like this...
....
sphere{0,1 scale 100*(rand(R) + "some tiny positive value")
....
.... even though rand() 'never' hits exactly 0.0, in my experience.
Post a reply to this message
|
 |