Steven D'Aprano wrote:
def pinned_gaussian(a, b, mu, sigma):
"""Return a Gaussian random number pinned to [a, b]."""
return min(b, max(a, random.gauss(mu, sigma)))
def truncated_gauss(a, b, mu, sigma):
"""Return a random number from a truncated Gaussian distribution."""
while 1:
On Fri, 26 Feb 2010 13:26:44 -0800, pistacchio wrote:
> hi,
> i'm trying the random.gauss function. can anyone explain how to get a
> number between a given range? like, from 0 to 20 with an average of 10?
That's not what a Gaussian distribution does. It has an infinite range.
Are you sure you w
On Feb 26, 1:26 pm, pistacchio wrote:
> hi,
> i'm trying the random.gauss function. can anyone explain how to get a
> number between a given range? like, from 0 to 20 with an average of
> 10? and how to determine the "steep" of the curve? i've never studied
> it, so mu and sigma don't really tell
thanks, betadistribute did the work... and i learned a new thing!
On 26 Feb, 22:56, Robert Kern wrote:
> On 2010-02-26 15:26 PM, pistacchio wrote:
>
> > hi,
> > i'm trying the random.gauss function. can anyone explain how to get a
> > number between a given range?
>
> You don't. The Gaussian dist
On 2010-02-26 15:26 PM, pistacchio wrote:
hi,
i'm trying the random.gauss function. can anyone explain how to get a
number between a given range?
You don't. The Gaussian distribution has infinite range. The best you can do
with the standard library is to keep sampling until you get a number in
hi,
i'm trying the random.gauss function. can anyone explain how to get a
number between a given range? like, from 0 to 20 with an average of
10? and how to determine the "steep" of the curve? i've never studied
it, so mu and sigma don't really tell me a thing.
thanks in advange
--
http://mail.py