From: thinke365 on

such as uniform distribution, Normal distribution or poisson distribution.
is there any package that can be used to generate such random numbers.

--
View this message in context: http://old.nabble.com/how-to-generate-random-numbers-that-satisfy-certain-distribution-tp27288180p27288180.html
Sent from the Python - python-list mailing list archive at Nabble.com.

From: Ravi on
On Jan 23, 10:37 pm, thinke365 <thinke...(a)gmail.com> wrote:
> such as uniform distribution, Normal distribution or poisson distribution..
> is there any package that can be used to generate such random numbers.
>
> --
> View this message in context:http://old.nabble.com/how-to-generate-random-numbers-that-satisfy-cer...
> Sent from the Python - python-list mailing list archive at Nabble.com.

Did you try random package?
From: thinke365 on



Bugzilla from ra.ravi.rav(a)gmail.com wrote:
>
> On Jan 23, 10:37 pm, thinke365 <thinke...(a)gmail.com> wrote:
>> such as uniform distribution, Normal distribution or poisson
>> distribution.
>> is there any package that can be used to generate such random numbers.
>>
>> --
>> View this message in
>> context:http://old.nabble.com/how-to-generate-random-numbers-that-satisfy-cer...
>> Sent from the Python - python-list mailing list archive at Nabble.com.
>
> Did you try random package?
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>

of course i have tried random package, but can this package generate random
sequence that satisfy possion distribution , normal distribution and uniform
distribution

--
View this message in context: http://old.nabble.com/how-to-generate-random-numbers-that-satisfy-certain-distribution-tp27288180p27288996.html
Sent from the Python - python-list mailing list archive at Nabble.com.

From: Peter Chant on
thinke365 wrote:

>
> such as uniform distribution, Normal distribution or poisson distribution.
> is there any package that can be used to generate such random numbers.
>

I remeber being told that adding up 12 random numbers in the range 0-1
(which is what most computer random number genertors at the time chucked
out) and subtracted 6 gives a pretty good normal distribution. I think I
did try it once and it failed, but I must have done something odd.

--
http://www.petezilla.co.uk

From: Arnaud Delobelle on
thinke365 <thinke365(a)gmail.com> writes:

> such as uniform distribution, Normal distribution or poisson distribution.
> is there any package that can be used to generate such random numbers.

It's all in the standard library, the module is called -surprisingly-
'random'.

- use random.uniform for the uniform distributions
- use random normalvariate for normal distributions

There isn't a Poisson distribution function, but there is a expovariate
function. I think you can get poisson like this, but take it with a
grain of salt because my probability skills are very rusty!

import random
import itertools

def poisson(l):
e = random.expovariate
acc = 0.0
for n in itertools.count():
acc += e(l)
if acc >= 1.0:
return n

--
Arnaud