3 ms·
> The holy grail of random float generation is a function that takes two bounds and can generate ALL representable floating point numbers within the given bound
by toast0 3y ago
> The holy grail of random float generation is a function that takes two bounds and can generate ALL representable floating point numbers within the given bounds with the proper distribution, here uniform (and does so efficiently).
Uniform as in all representable numbers have equal probability? Or uniform as in approximating a uniform distribution over real numbers?
- camel-cdr 3y agoUniform over the real numbers.
- StefanKarpinski 3y agoIt’s a little unclear what you mean by that without further explanation. Do you mean that conceptually one selects a real number at random and then rounds that real number to the closest representable float? (And if so, which rounding mode?)
- zamadatix 3y agoFloats aren't uniformly distributed over the reals (e.g. larger floats are sparser) so the above approach simply tries to account for that when generating the number by using a precisely counteracting non-uniform selection method which will result in even distribution in relation to where in the reals the picks are. It does so directly.