Package org.apache.commons.math4.util
Class CombinatoricsUtils
- java.lang.Object
-
- org.apache.commons.math4.util.CombinatoricsUtils
-
public final class CombinatoricsUtils extends java.lang.ObjectCombinatorial utilities.- Since:
- 3.3
-
-
Method Summary
Modifier and Type Method Description 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 Detail
-
stirlingS2
public static long stirlingS2(int n, int k) throws NotPositiveException, NumberIsTooLargeException, MathArithmeticExceptionReturns the Stirling number of the second kind, "S(n,k)", the number of ways of partitioning ann-element set intoknon-empty subsets.The preconditions are
0 <= k <= n(otherwiseNotPositiveExceptionis thrown)- Parameters:
n- the size of the setk- the number of non-empty subsets- Returns:
S(n,k)- Throws:
NotPositiveException- ifk < 0.NumberIsTooLargeException- ifk > n.MathArithmeticException- 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)- Since:
- 3.1
-
-