dimanche 26 août 2018

Create possion distribution wiith N random numbers whose sum is a constant (C)

I want to generate a random possion number distribution where the sum of the generate number is 1000 and the lower-upper bound of the distribution is (3-30).

I can use numpy to generate random number:

 
In [2]: np.random.poisson(5, 150)
array([ 4,  4,  6,  4,  8,  6,  4,  2,  6,  8,  8,  8,  1,  4,  3,  4,  1,
        3,  7,  6,  7,  4,  5,  5,  7,  6,  5,  3,  3,  5,  4,  6,  2,  0,
        3,  5,  6,  2,  5,  2,  4,  7,  4,  7,  8,  5,  6,  1,  4,  4,  7,
        4,  7,  2,  7,  4,  3,  8, 10,  2,  5,  7,  6,  3,  5,  7,  8,  5,
        4,  7,  8,  8,  2,  2, 10,  6,  3,  5,  2,  5,  5,  6,  4,  6,  4,
        0,  4,  3,  5,  8,  6,  7,  4,  4,  4,  3,  3,  4,  4,  6,  7,  6,
        3,  9,  7,  7,  4,  5,  2,  4,  3,  6,  5,  6,  3,  6,  8,  9,  6,
        3,  4,  4,  7,  3,  9, 12,  4,  5,  5,  7,  6,  5,  2, 10,  1,  3,
        4,  4,  6,  5,  4,  4,  7,  5,  6,  5,  7,  2,  5,  5])


But, I want to add something more to it :

- The random number should be minimal of 3 and max of 30 
- The sum of the generated random number should be 1000.

I know, I may not be creating an exact possion distribution if I manipulate. But, I want something like possion but with suggested controls.




Aucun commentaire:

Enregistrer un commentaire