mardi 27 avril 2021

How to uniformly sample integer partitions of n into m parts, with each part in {0,..,k}

How do you generate uniformly random samples for an integer n, number of parts m and upper bound of parts k, such that:

  1. all m parts sum to n
  2. 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