random number including 1 - i.e. [0,1]
Mark Dickinson
dickinsm at gmail.com
Wed Jun 10 15:46:15 EDT 2009
On Jun 10, 8:15 pm, Robert Kern <robert.k... at gmail.com> wrote:
> On 2009-06-10 13:53, Terry Reedy wrote:
> > 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
> discussed elsewhere.
I find it difficult to see how such a disclaimer would have any
practical
value, without also knowing *which* values of a and b are affected.
It can certainly be useful to know that endpoints *aren't* included
where
that's true. For example, knowing that random.random() can never
produce the
value 1.0 means that one can safely generate a mean 1 exponential
variate with
-log(1-random.random()), without worrying about the possibility of
taking log
of 0.
But I don't know why it would be useful to know that endpoints *are*
sometimes
included, without knowing exactly when.
Mark
More information about the Python-list
mailing list