How do you generate uniformly random samples for an integer n, number of parts m and upper bound of parts k, such that:
- all m parts sum to n
- each individual part is an integer from 0 to k (including both 0 and k)
For example, for n=2, m=3, k=4 all possible samples are:
[0,0,2]
[0,2,0]
[2,0,0]
[0,1,1]
[1,1,0]
[1,0,1]
Aucun commentaire:
Enregistrer un commentaire