random number including 1 - i.e. [0,1]
ebonak at hotmail.com
Tue Jun 9 17:33:39 EDT 2009
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.
ps: I'm confused by the docs for uniform():
Return a random floating point number N such that a <= N <= b for a <= b
this seems to imply an inclusive range, ie. [a,b]
but this seems to contradict it:
In : random.uniform?
Base Class: <type 'instancemethod'>
String Form: <bound method Random.uniform of <random.Random object at 0x8c50754>>
Definition: random.uniform(self, a, b)
Get a random number in the range [a, b).
More information about the Python-list