random number including 1 - i.e. [0,1]
Mark Dickinson
dickinsm at gmail.com
Wed Jun 10 21:00:45 CEST 2009
On Jun 10, 6:57 pm, Mensanator <mensana... at aol.com> wrote:
> On Jun 10, 12:37 pm, Mark Dickinson <dicki... at gmail.com> wrote:
>
> > On Jun 10, 6:21 pm, Mensanator <mensana... at aol.com> 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.
>
> > Exactly which bit of the 2.6.2 documentation do you think is
> > incorrect? The documentation for random.uniform says:
>
> > """Return a random floating point number N such that
> > a <= N <= b for a <= b and b <= N <= a for b < a."""
>
> > And that's precisely what it does.
>
> I didn't say it didn't.
>
> > Nowhere does the documentation say that *every*
>
> Unless qualified otherwise, that statement implies "for all (a,b)".
Sure. For all a <= b, it's true that a <= uniform(a, b) <= b.
And similarly for b <= a.
I really don't see the problem: the documentation is both
technically correct and useful in practice. The assertion
implicit in the name and description of the random.uniform
function is that, to a very good approximation, the values
produced by random.uniform(a, b) will be uniformly
distributed on the closed interval [a, b]. And that's true
(at least within the limits of floating-point arithmetic).
Can you think of a single practical situation where it would
matter that, for some values of a and b, uniform(a, b) can
never produce the value b?
Mark
More information about the Python-list
mailing list