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

Miles Kaufmann milesck at umich.edu
Tue Jun 9 19:16:57 EDT 2009


On Jun 9, 2009, at 7:05 PM, Mensanator wrote:

> On Jun 9, 4:33 pm, Esmail 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.

I'm curious what algorithm calls for random numbers on a closed  
interval.

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

-Miles




More information about the Python-list mailing list