polymerist.maths.combinatorics.numbers
Utilities for calculating fundamental combinatorial numbers
Attributes
Functions
|
Returns the value of -1^n (useful for alternating sums) |
|
Calculates a generalized binomial coefficient |
|
Calculates a multiset coefficient |
|
Calculate the multinomial coefficient of a set of multiplicities |
|
Calculate the multinomial coefficient of a set of multiplicities |
|
Calculates the n-th Catalan number |
|
Calculates the n-th pentagonal number |
|
Calculates the Stirling number of the second kind S(n, k) |
|
Calculates the Stirling number of the first kind c(n, k) |
|
Calculates the n-th Bell number |
|
Calculates the n-th Bernoulli number |
|
Computes a list of the first N Bernoulli numbers using the Akiyama-Tanigawa algorithm |
|
Gives number of all labelled graphs on N nodes |
|
Gives array of number labelled graphs with one connected component on N nodes |
Module Contents
- polymerist.maths.combinatorics.numbers.alt_sign(n: int) int[source]
Returns the value of -1^n (useful for alternating sums)
- polymerist.maths.combinatorics.numbers.binomial_coeff(n: complex, k: int) float[source]
Calculates a generalized binomial coefficient Counts the number of distinct ways to make and unordered selection of k elemnts from a set of n items
- polymerist.maths.combinatorics.numbers.choose
- polymerist.maths.combinatorics.numbers.multiset_coeff(n: int, k: int) float[source]
Calculates a multiset coefficient Counts the number of ways to form a multiset of cardinality n from a support of size k
- polymerist.maths.combinatorics.numbers.multinomial_coeff(multips: Iterable[int]) float[source]
Calculate the multinomial coefficient of a set of multiplicities Counts the number of distinct permutations of a multiset with given multiplicites
- polymerist.maths.combinatorics.numbers.multinomial_coeff_native(multips: Iterable[int]) float[source]
Calculate the multinomial coefficient of a set of multiplicities Counts the number of distinct permutations of a multiset with given multiplicites
Native Python implementation of multinomial_coeff() which is slightly slower but requires no imports
- polymerist.maths.combinatorics.numbers.catalan(n: int) float[source]
Calculates the n-th Catalan number Counts dozens of different things, including the number of monotonic 2D random walks and the number of valid (i.e. fully closed) groupings of n pairs of parentheses
- polymerist.maths.combinatorics.numbers.pentagonal(n: int) float[source]
Calculates the n-th pentagonal number Counts the number of points in n “concentric” pentagon figures which share a corner vertex
Related to the generating function for numbers of partitions
- polymerist.maths.combinatorics.numbers.stirling_second(n: int, k: int) float[source]
Calculates the Stirling number of the second kind S(n, k) Counts the number of ways to partition n objects into k non-empty pairwise-disjoint subsets
Recurrence used as listed in NIST DLMF (https://dlmf.nist.gov/26.8)
- polymerist.maths.combinatorics.numbers.stirling_first(n: int, k: int) float[source]
Calculates the Stirling number of the first kind c(n, k) Counts the number of ways to to decompose a permutation of n objects into k cycles
Recurrence used as listed in Abramowitz ans Stegun (https://www.convertit.com/Go/ConvertIt/Reference/AMS55.ASP?Res=150&Page=825)
- polymerist.maths.combinatorics.numbers.bell(n: int) float[source]
Calculates the n-th Bell number Counts the number of ways to partition n objects into any number of non-empty pairwise-disjoint subsets
- polymerist.maths.combinatorics.numbers.bernoulli(n: int) int[source]
Calculates the n-th Bernoulli number Related to the sums of powers of integers (via Faulhalber’s formula)
- polymerist.maths.combinatorics.numbers.bernoulli_up_to(N: int) list[fractions.Fraction][source]
Computes a list of the first N Bernoulli numbers using the Akiyama-Tanigawa algorithm