random number including 1 - i.e. [0,1]
mensanator at aol.com
Tue Jun 9 19:05:05 EDT 2009
On Jun 9, 4:33 pm, Esmail <ebo... at hotmail.com> wrote:
> 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():
> 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?
Help on method uniform in module random:
uniform(self, a, b) method of random.Random instance
Get a random number in the range [a, b).
> this seems to imply an inclusive range, ie. [a,b]
> but this seems to contradict it:
> In : random.uniform?
> Type: instancemethod
> Base Class: <type 'instancemethod'>
> String Form: <bound method Random.uniform of <random.Random object at 0x8c50754>>
> Namespace: Interactive
> File: /usr/lib/python2.6/random.py
> Definition: random.uniform(self, a, b)
> Get a random number in the range [a, b).
More information about the Python-list