Jeez what a luck.. a full zero from a random sampler ! ![]()
Jokes a part, there're exactly zero chances for a full of anything in a stochastic simulation.
Repro steps. Open Maya (arnold 6.2.1.0). Put a sphere in the scene. Press F in persp to bring it closer. Add a skydome with any image. Previously you coded a BRDF (even empty) where you just check for zeros in the sample routine from the given default rnds. Discovered this because my code was crashing with a division by zero.
Arnold uses 32-bit floats, which means there are only a finite number of values that can be represented, so the odds are not 1 in infinity of getting exactly zero but roughly 1 in 4 billion. What's more, because we're not trying to get just any random float value but a random number in [0,1), that's 0 all the way to 0.9999999..., the possible values are really more like 1 in a few million.
If you are casting millions of rays, the odds of getting exactly zero goes dramatically up, so it's actually pretty likely this will happen.
If you don't want 0 to happen but are OK with 1, take the random value X and transform it by 1-X. Then you'll have a value that goes from (0,1].
It is true that we use float and not reals, but there are still one billion numbers in the 0-1 floating-point range. Whenever we ask for a random number there is always a one-in-a-billion chance of getting an exact zero, so getting one as long as it's a chance is generally an indication of having a somehow biased sampler. However that's an interesting thing to research, I'll dig with this a bit more formally when time. Thanks for the inputs.
You're right, there are a billion floats in [0,1), but the arnold random number generator produces uniformly distributed values from [0,1) for which there's just a few million values.
Here's a page I found which goes into more details: https://lemire.me/blog/2017/02/28/how-many-floating-point-numbers-are-in-the-interval-01/
even though your computer can represent about 230 distinct and normal floating-point numbers in [0,1), chances are good that your random generator only produces 224 distinct floating-point numbers in the interval [0,1)
To some extent it's still debatable if you look at comments there. Btw, that's interesting that there're more fp numbers around zero so for a truly uniform distribution of fp random variates one needs a non uniform distribution of fp numbers. Just to say that's not necessary that the characterization of some random generator properties belong to its final outcome representation (and viceversa).
Eventually let me say I'm super cool with your sampler and that a minor problem is just that I've to use another one as 3 rnd numbers(sample fnc) ain't enough sometime and would be great to have a way to ask for more.
Sie finden nicht, was Sie suchen? Fragen Sie die Community oder teilen Sie Ihr Wissen mit anderen.