Class Stirling
java.lang.Object
org.apache.commons.numbers.combinatorics.Stirling
Computation of Stirling numbers.
- Since:
- 1.2
-
Method Summary
Modifier and TypeMethodDescriptionstatic longstirlingS1(int n, int k) Returns the signed Stirling number of the first kind, "s(n,k)".static longstirlingS2(int n, int k) Returns the Stirling number of the second kind, "S(n,k)", the number of ways of partitioning ann-element set intoknon-empty subsets.
-
Method Details
-
stirlingS1
Returns the signed Stirling number of the first kind, "s(n,k)". The number of permutations ofnelements which contain exactlykpermutation cycles is the nonnegative number:|s(n,k)| = (-1)^(n-k) s(n,k)- Parameters:
n- Size of the setk- Number of permutation cycles (0 <= k <= n)- Returns:
s(n,k)- Throws:
IllegalArgumentException- ifn < 0,k < 0ork > n.ArithmeticException- if some overflow happens, typically for n exceeding 20 (s(n,n-1) is handled specifically and does not overflow)
-
stirlingS2
Returns the Stirling number of the second kind, "S(n,k)", the number of ways of partitioning ann-element set intoknon-empty subsets.- Parameters:
n- Size of the setk- Number of non-empty subsets (0 <= k <= n)- Returns:
S(n,k)- Throws:
IllegalArgumentException- ifn < 0,k < 0ork > n.ArithmeticException- if some overflow happens, typically for n exceeding 25 and k between 20 and n-2 (S(n,n-1) is handled specifically and does not overflow)
-