Considering the current generation scheme more or less has
julia> eps(nextfloat(1.0f0))
1.1920929f-7
julia> eps(prevfloat(2.0f0))
1.1920929f-7
as its accuracy, yes. I agree though that requiring to know this is neither ergonomic nor good for a user On the other hand, one could also argue that this is inevitable depending on which value you pick; don’t you get the same “overweighing” on the other end of the interval, no matter whether this is fixed for small numbers? After all, the “proper” bin has a higher precision than the interval we currently generate too:
julia> eps(prevfloat(1f0))
5.9604645f-8
Either way, if this is changed, it should definitely be clarified that rand()
samples from the representable floating point values in the interval [0, 1)
, and not from the real number line.