Combinatorial functions.
The binomial coefficient. binomial(n, m) returns n ! / ((n - m) ! * m !).
n must be a positive integer and m must be a non-negative integer. For convinience, binomial(n, n+i) = 0 for positive i, and binomial(0,0) = 1.
In other cases, it raises an exception.
Return n! for non negative integer n.
Return n-th Bernoulli number.
(new in 0.4.0)
Return n-th Catalan number.
(new in 0.4.0)
Return n-th Euler number.
(new in 0.90.0)
Generate indeces of m elment subsets of n element set.
For example:
>>> for idx in combinationIndexGenerator(5,3): ... print idx ... [0, 1, 2] [0, 1, 3] [0, 1, 4] [0, 2, 3] [0, 2, 4] [0, 3, 4] [1, 2, 3] [1, 2, 4] [1, 3, 4] [2, 3, 4] >>>
(moved from zassenhaus.py in 0.5.0)
Return the falling factorial; n to the m falling, i.e. n(n-1)..(n-m+1).
(new in 0.5.0)
Return the rising factorial; n to the m rising, i.e. n(n+1)..(n+m-1).
(new in 0.5.0)
Return multinomial coefficient.
parts MUST be a sequence of natural numbers and n==sum(parts) holds.
(new in 0.5.0)
Generate partitions of n.
If maxi is given, then addends are limited to at most maxi.
(new in 0.5.0)
Return n-th Bell number.
The Bell number b is defined by:
b(n) = \sum_{i=0}^{n} S(n, i)
where S denotes Stirling number of the second kind.
(new in 0.7.0)
Stirling number of the first kind.
Let s denote the Stirling number, (x)_n falling factorial, then
(x)_n = \sum_{i=0}^{n} s(n, i) * x**i
and s satisfies the recurrence relation:
s(n, m) = s(n-1, m-1) - (n-1)*S(n-1, m)
(new in 0.7.0)
Stirling number of the second kind.
Let S denote the Stirling number, (x)_i falling factorial, then:
x**n = \sum_{i=0}^{n} S(n, i) * (x)_i
S satisfies:
S(n, m) = S(n-1, m-1) + m*S(n-1, m)
(new in 0.7.0)