random number including 1 - i.e. [0,1]
robert.kern at gmail.com
Wed Jun 10 15:15:58 EDT 2009
On 2009-06-10 13:53, Terry Reedy wrote:
> Mensanator wrote:
>> So, the 2.6.2 documentation is STILL wrong. Before it implied
>> it was ALWAYS a semi-open interval, and now it says it's ALWAYS
>> a closed interval. But neither is correct.
> If a < x < b is true, then a <= x <= b is true.
> But docs say that in general end point values might happen. They do not
> say that in every particular case, they will happen.
I'm not so sure. Context is important. When discussing the bounds of random
number generators, specifying <= instead of < strongly suggests that the bound
is one of the possible results. I've had to read a lot of random number
generator documentation in my time.
To take the point to absurdity, it would be wrong for the function to return
just values within (a+0.25*b, a+0.75*b) even though the docs "just" say that the
result will be between a and b.
> A full technical discussion does not below in the docs, in my opinion. A
> wike article would be fine.
True. However, a brief note that "Due to floating point arithmetic, for some
values of a and b, b may or may not be one of the possible generated results."
might be worthwhile. The actual details of *why* this is the case can be
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list