powered by
Sampling a partition is a two-step process:
The k parts of the partion are sampled in the loop. This implies that the first partition p is a random number between 1 and 1+n-k. The next partition is sampled from 1 to 1+n-k-p.
We permute the partitions.
rndPartition(n, k)
The integer partition of n in k parts.
The integer to divide.
Number of parts.
rndPartition(10, 4)
Run the code above in your browser using DataLab