Class LogBinomialCoefficient
- java.lang.Object
-
- org.apache.commons.numbers.combinatorics.LogBinomialCoefficient
-
public final class LogBinomialCoefficient extends java.lang.ObjectNatural logarithm of the binomial coefficient. It is "n choose k", the number ofk-element subsets that can be selected from ann-element set.
-
-
Field Summary
Fields Modifier and Type Field Description private static intLIMIT_M_DOUBLEThe maximum m that can be computed without overflow of a double for any n.private static intLIMIT_N_DOUBLEThe maximum n that can be computed without overflow of a double for an m.private static intLIMIT_N_LONGThe maximum n that can be computed without overflow of a long for any m.
-
Constructor Summary
Constructors Modifier Constructor Description privateLogBinomialCoefficient()Private constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublevalue(int n, int k)Computes the logarithm of the binomial coefficient.
-
-
-
Field Detail
-
LIMIT_N_LONG
private static final int LIMIT_N_LONG
The maximum n that can be computed without overflow of a long for any m.C(66, 33) < 2^63.- See Also:
- Constant Field Values
-
LIMIT_N_DOUBLE
private static final int LIMIT_N_DOUBLE
The maximum n that can be computed without overflow of a double for an m. C(1029, 514) ~ 1.43e308.- See Also:
- Constant Field Values
-
LIMIT_M_DOUBLE
private static final int LIMIT_M_DOUBLE
The maximum m that can be computed without overflow of a double for any n. C(2147483647, 37) ~ 1.39e302.- See Also:
- Constant Field Values
-
-
Method Detail
-
value
public static double value(int n, int k)Computes the logarithm of the binomial coefficient.This returns a finite result for any valid
n choose k.- Parameters:
n- Size of the set.k- Size of the subsets to be counted.- Returns:
log(n choose k).- Throws:
java.lang.IllegalArgumentException- ifn < 0,k < 0ork > n.
-
-