|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.math3.util.CombinatoricsUtils
public final class CombinatoricsUtils
Combinatorial utilities.
| Method Summary | |
|---|---|
static long |
binomialCoefficient(int n,
int k)
Returns an exact representation of the Binomial Coefficient, " n choose k", the number of
k-element subsets that can be selected from an
n-element set. |
static double |
binomialCoefficientDouble(int n,
int k)
Returns a double representation of the Binomial
Coefficient, "n choose k", the number of
k-element subsets that can be selected from an
n-element set. |
static double |
binomialCoefficientLog(int n,
int k)
Returns the natural log of the Binomial
Coefficient, "n choose k", the number of
k-element subsets that can be selected from an
n-element set. |
static void |
checkBinomial(int n,
int k)
Check binomial preconditions. |
static long |
factorial(int n)
Returns n!. |
static double |
factorialDouble(int n)
Compute n!, the factorial of n (the product of the numbers 1 to n), as a
double. |
static double |
factorialLog(int n)
Compute the natural logarithm of the factorial of n. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static long binomialCoefficient(int n,
int k)
throws NotPositiveException,
NumberIsTooLargeException,
MathArithmeticException
n choose k", the number of
k-element subsets that can be selected from an
n-element set.
Preconditions:
0 <= k <= n (otherwise
MathIllegalArgumentException is thrown)long. The
largest value of n for which all coefficients are
< Long.MAX_VALUE is 66. If the computed value exceeds
Long.MAX_VALUE an ArithMeticException is
thrown.
n - the size of the setk - the size of the subsets to be counted
n choose k
NotPositiveException - if n < 0.
NumberIsTooLargeException - if k > n.
MathArithmeticException - if the result is too large to be
represented by a long integer.
public static double binomialCoefficientDouble(int n,
int k)
throws NotPositiveException,
NumberIsTooLargeException,
MathArithmeticException
double representation of the Binomial
Coefficient, "n choose k", the number of
k-element subsets that can be selected from an
n-element set.
Preconditions:
0 <= k <= n (otherwise
IllegalArgumentException is thrown)double. The
largest value of n for which all coefficients are <
Double.MAX_VALUE is 1029. If the computed value exceeds Double.MAX_VALUE,
Double.POSITIVE_INFINITY is returned
n - the size of the setk - the size of the subsets to be counted
n choose k
NotPositiveException - if n < 0.
NumberIsTooLargeException - if k > n.
MathArithmeticException - if the result is too large to be
represented by a long integer.
public static double binomialCoefficientLog(int n,
int k)
throws NotPositiveException,
NumberIsTooLargeException,
MathArithmeticException
log of the Binomial
Coefficient, "n choose k", the number of
k-element subsets that can be selected from an
n-element set.
Preconditions:
0 <= k <= n (otherwise
IllegalArgumentException is thrown)
n - the size of the setk - the size of the subsets to be counted
n choose k
NotPositiveException - if n < 0.
NumberIsTooLargeException - if k > n.
MathArithmeticException - if the result is too large to be
represented by a long integer.
public static long factorial(int n)
throws NotPositiveException,
MathArithmeticException
n Factorial, the
product of the numbers 1,...,n.
Preconditions:
n >= 0 (otherwise
IllegalArgumentException is thrown)long. The
largest value of n for which n! <
Long.MAX_VALUE} is 20. If the computed value exceeds Long.MAX_VALUE
an ArithMeticException is thrown.
n - argument
n!
MathArithmeticException - if the result is too large to be represented
by a long.
NotPositiveException - if n < 0.
MathArithmeticException - if n > 20: The factorial value is too
large to fit in a long.
public static double factorialDouble(int n)
throws NotPositiveException
n (the product of the numbers 1 to n), as a
double.
The result should be small enough to fit into a double: The
largest n for which n! < Double.MAX_VALUE is 170.
If the computed value exceeds Double.MAX_VALUE,
Double.POSITIVE_INFINITY is returned.
n - Argument.
n!
NotPositiveException - if n < 0.
public static double factorialLog(int n)
throws NotPositiveException
n.
n - Argument.
n!
NotPositiveException - if n < 0.
public static void checkBinomial(int n,
int k)
throws NumberIsTooLargeException,
NotPositiveException
n - Size of the set.k - Size of the subsets to be counted.
NotPositiveException - if n < 0.
NumberIsTooLargeException - if k > n.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||