polymerist.maths.combinatorics.numbers ====================================== .. py:module:: polymerist.maths.combinatorics.numbers .. autoapi-nested-parse:: Utilities for calculating fundamental combinatorial numbers Attributes ---------- .. autoapisummary:: polymerist.maths.combinatorics.numbers.choose Functions --------- .. autoapisummary:: polymerist.maths.combinatorics.numbers.alt_sign polymerist.maths.combinatorics.numbers.binomial_coeff polymerist.maths.combinatorics.numbers.multiset_coeff polymerist.maths.combinatorics.numbers.multinomial_coeff polymerist.maths.combinatorics.numbers.multinomial_coeff_native polymerist.maths.combinatorics.numbers.catalan polymerist.maths.combinatorics.numbers.pentagonal polymerist.maths.combinatorics.numbers.stirling_second polymerist.maths.combinatorics.numbers.stirling_first polymerist.maths.combinatorics.numbers.bell polymerist.maths.combinatorics.numbers.bernoulli polymerist.maths.combinatorics.numbers.bernoulli_up_to polymerist.maths.combinatorics.numbers.count_labelled_graphs polymerist.maths.combinatorics.numbers.count_connected_labelled_graphs Module Contents --------------- .. py:function:: alt_sign(n: int) -> int Returns the value of -1^n (useful for alternating sums) .. py:function:: binomial_coeff(n: complex, k: int) -> float 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 .. py:data:: choose .. py:function:: multiset_coeff(n: int, k: int) -> float Calculates a multiset coefficient Counts the number of ways to form a multiset of cardinality n from a support of size k .. py:function:: multinomial_coeff(multips: Iterable[int]) -> float Calculate the multinomial coefficient of a set of multiplicities Counts the number of distinct permutations of a multiset with given multiplicites .. py:function:: multinomial_coeff_native(multips: Iterable[int]) -> float 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 .. py:function:: catalan(n: int) -> float 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 .. py:function:: pentagonal(n: int) -> float 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 .. py:function:: stirling_second(n: int, k: int) -> float 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) .. py:function:: stirling_first(n: int, k: int) -> float 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) .. py:function:: bell(n: int) -> float Calculates the n-th Bell number Counts the number of ways to partition n objects into any number of non-empty pairwise-disjoint subsets .. py:function:: bernoulli(n: int) -> int Calculates the n-th Bernoulli number Related to the sums of powers of integers (via Faulhalber's formula) .. py:function:: bernoulli_up_to(N: int) -> list[fractions.Fraction] Computes a list of the first N Bernoulli numbers using the Akiyama-Tanigawa algorithm .. py:function:: count_labelled_graphs(N: int) -> int Gives number of all labelled graphs on N nodes .. py:function:: count_connected_labelled_graphs(n: int) -> float Gives array of number labelled graphs with one connected component on N nodes