default random object?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sun Feb 15 11:06:23 PST 2009
Joel C. Salomon wrote:
> Don wrote:
>> There's a couple of difficult situations involving floating-point numbers.
> <snip>
>> * any floating point range which includes 0 is difficult, because there
>> are so many numbers which are almost zero. The probability of getting a
>> zero for an 80-bit real is so small that you probably wouldn't encounter
>> it in your lifetime. I think this weakens arguments based on analogy
>> with the integer case.
>
> In that vein: for the floating-point case, do you want to emulate a
> “true” uniform random distribution in the range [x, y), or make every
> expressible IEEE 754 value in that range come out with equal likelihood?
> One is the logarithm of the other, in some sense.
The former! Otherwise the distribution will be biased toward numbers
closer to 0 (which are denser than larger numbers).
That being said, for the range [0, 1) the exponent is constant so it's
nice to generate all possible mantissa values, something that simple
division by uint.max does not achieve.
Andrei
More information about the Digitalmars-d
mailing list