mardi 4 août 2015

How to generate a list of random numbers so their sum would be equal to a randomly chosen number

I want to generate a list of random distribution of numbers so their sum would be equal to a randomly chosen number. For example, if randomly chosen number is 5, the distribution would be [1 2 2] or [2 3] or [1 1 1 2] and so on. Any suggestions are welcome!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire