non-uniform distribution

Etienne Rousee etienne at rousee.org
Sat Jun 12 07:08:28 EDT 2010


Le 12/06/2010 12:05, Javier Montoya a écrit :
> I need to generate a vector of random float numbers between [0,1] such
> that their sum equals 1 and that are distributed non-uniformly.
> Is there any python function that generates such a vector?

Let f any function (injective is better).
Let a1,...,an n numbers uniformly distributed.
Let s the sum of f(a1),...,f(an).

f(a1)/s, ... , f(an)/s is what you want.

You have to choose f to obtain the distribution you prefer.

-- 

Etienne




More information about the Python-list mailing list