random number including 1 - i.e. [0,1]

Mensanator mensanator at aol.com
Wed Jun 10 02:27:13 CEST 2009


On Jun 9, 6:12 pm, Robert Kern <robert.k... at gmail.com> wrote:
> On 2009-06-09 18:05, Mensanator wrote:
>
>
>
>
>
> > On Jun 9, 4:33 pm, Esmail<ebo... at hotmail.com>  wrote:
> >> Hi,
>
> >> random.random() will generate a random value in the range [0, 1).
>
> >> Is there an easy way to generate random values in the range [0, 1]?
> >> I.e., including 1?
>
> >> I am implementing an algorithm and want to stay as true to the
> >> original design specifications as possible though I suppose the
> >> difference between the two max values might be minimal.
>
> >> Thanks,
> >> Esmail
>
> >> ps: I'm confused by the docs for uniform():
>
> >> random.uniform(a, b)
> >>       Return a random floating point number N such that a<= N<= b for a<= b
>
> > That's wrong. Where did you get it?
>
> http://docs.python.org/library/random

Ok, but the 2.6.1 docs say

random.uniform(a, b)
Return a random floating point number N such that a <= N < b
for a <= b and b <= N < a for b < a.

Is that a new feature of 2.6.2?

>
> --
> Robert Kern
>
> "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- Hide quoted text -
>
> - Show quoted text -




More information about the Python-list mailing list