UserManual

combinatorial

Combinatorial functions.

Functions

binomial(n, m)

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.

factorial(n)

Return n! for non negative integer n.

bernoulli(n)

Return n-th Bernoulli number.
(new in 0.4.0)

catalan(n)

Return n-th Catalan number.
(new in 0.4.0)

combinationIndexGenerator(n, m)

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)

fallingfactorial(n, m)

Return the falling factorial; n to the m falling, i.e. n(n-1)..(n-m+1).
(new in 0.5.0)

risingfactorial(n, m)

Return the rising factorial; n to the m rising, i.e. n(n+1)..(n+m-1).
(new in 0.5.0)

multinomial(n, parts)

Return multinomial coefficient.
parts MUST be a sequence of natural numbers and n==sum(parts) holds.
(new in 0.5.0)

partitionGenerator(n [, maxi])

Generate partitions of n.
If maxi is given, then addends are limited to at most maxi.
(new in 0.5.0)


Last-modified: 2006-01-01 (Æü) 13:30:44