The documentation for Distributions.Uniform()
states that it allows to draw a value in [a,b]
(bounds included). Looking into the code, it seems that the rand()
function from Base
is used along with some affine transformation. Since rand()
returns a value in [0,1)
(right bound excluded), I am curious to know how Uniform()
translates that to a closed interval. Or is it defined in that way only to take into account possible rounding errors?
You make a good point, but I donāt see anywhere that the documentation explicitly says that the bounds are included.
A uniform distribution has zero probability of producing either bound.
@dpsanders The documentations states:
Uniform() # Uniform distribution over [0, 1]
Uniform(a, b) # Uniform distribution over [a, b]
My understanding is that values returned are taken from the closed intervals [0,1]
and [a,b]
respectively.
Except we know that we are not really drawing from a continuous uniform distribution. The probability of returning any discrete value from the interval is small but not zero, and it gets larger the smaller the size of the floating-point type considered.
As you say, there is a disconnect between the mathematical concept, as used in āUniform distribution over [0, 1]ā with a closed interval, and the numerical reality.
It seems difficult to believe that including or not the right end-point will affect anything much statistically speaking, even with Float16
.
[Although a friend once had a bug that cropped up only after very long simulations, due to the fact thatthe right end-point was being produced in his case. It was then processed in a way that led to some kind of nonsensical calculation like log(0)
.]
See also previous discussions such as