how to generate random numbers that satisfy certain distribution

Paul Rubin no.email at nospam.invalid
Sat Jan 23 15:29:22 EST 2010


Peter Chant <peteRE at MpeteOzilla.Vco.ukE> writes:
> 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.

That gives you a binomial distribution on 12 trials, which approximates
a normal distribution when the number of trials is large.  12 isn't too
bad.  But there's a simpler way, the Box-Muller transform, that gives
you a pair drawn from a precisely normal distribution from two uniform
random samples:

  http://en.wikipedia.org/wiki/Box-Muller_transform 



More information about the Python-list mailing list