random generator

Paul Rubin phr-n2002a at nightsong.com
Tue Feb 5 03:32:36 EST 2002


"Fredrik Lundh" <fredrik at pythonware.com> writes:
> > Any will do, e.g., uniform, normal, etc.
> 
> does any of the "uniform" or "normal" generators in the standard
> random module do what you want?
> 
> http://www.python.org/doc/current/lib/module-random.html
> 
>     This module implements pseudo-random number generators
>     for various distributions. For integers, uniform selection from
>     a range. For sequences, uniform selection of a random element,
>     and a function to generate a random permutation of a list in-
>     place. On the real line, there are functions to compute uniform,
>     normal (Gaussian), lognormal, negative exponential, gamma,
>     and beta distributions. For generating distribution of angles,
>     the circular uniform and von Mises distributions are available.
> 
> no "etc" generator in there, though.

Skewness is a measure of the assymetry of a distribution.  I don't
remember the formula but it's similar to the formula for standard
deviation except it involves (x-mean)**3 instead of (x-mean)**2.  A
normal distribution (bell shaped curve) is symmetrical around the mean
so its skewness is zero.  Same for a uniform distribution (same
density everywhere).  Some of the other available distributions
(exponential etc.) are assymetrical and so they have nonzero skewness,
but the OP asked for a generator where you could just specify what
skewness you want.  The random module doesn't give a direct way to do
that.  You have to pick a distribution, then crunch out some integrals
and solve some equations to get the distribution parameters for the
skewness you want.

Further description:
http://www.everything2.net/index.pl?node=skewness



More information about the Python-list mailing list