Random double
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Wed Apr 24 07:58:35 PDT 2013
On 04/23/2013 10:59 PM, bearophile wrote:
> Also note by their nature doubles are not equally spread across the line of
> Reals, so getting a truly uniform distribution is hard or impossible.
More than that -- the number of unique values generated by the underlying RNG
should (for Mersenne Twister) be much smaller than the number of unique double
values in [-double.max, double.max], because the type used is uint32.
I think the infinities probably come from the fact that the returned random
value is generated by the following expression:
_a + (_b - _a) * cast(NumberType) (urng.front - urng.min)
/ (urng.max - urng.min);
So, you've got a double.max + (double.max - double.min) in there which evaluates
to inf.
More information about the Digitalmars-d-learn
mailing list