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

Robert Kern robert.kern at gmail.com
Wed Jun 10 01:12:52 CEST 2009


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

-- 
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




More information about the Python-list mailing list