#partition #random #combinatorics #algorithms #algorithm

random-partition

Generate approximately uniformly distributed random integer partitions

1 unstable release

0.1.0 Dec 14, 2022

#1492 in Math

28 downloads per month

MIT/Apache and LGPL-3.0+

10KB
150 lines

Description

Generate approximately uniformly distributed random integer partitions of a given size.

Algorithm

The algorithm is essentially the algorithm described here https://stackoverflow.com/questions/10287021/an-algorithm-for-randomly-generating-integer-partitions-of-a-particular-length with some core functions rewritten as dynamic programs to make the whole thing more efficient.


lib.rs:

Generate approximately uniformly distributed random integer partitions. So given natural numbers n, k find a sequence of natural (nonzero) p₁, ..., pₖ such that n = ∑ᵢ₌₁ᵏ pᵢ.

Dependencies

~4MB
~75K SLoC