Package htsjdk.variant.utils
Class BinomialCoefficientUtil
java.lang.Object
htsjdk.variant.utils.BinomialCoefficientUtil
A modified version of the Apache Math implementation of binomial
coefficient calculation
Derived from code within the CombinatoricsUtils and FastMath classes
within Commons Math3 (https://commons.apache.org/proper/commons-math/)
Included here for use in Genotype Likelihoods calculation, instead
of adding Commons Math3 as a dependency
Commons Math3 is licensed using the Apache License 2.0
Full text of this license can be found here:
https://www.apache.org/licenses/LICENSE-2.0.txt
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
This product includes software developed for Orekit by
CS Systèmes d'Information (http://www.c-s.fr/)
Copyright 2010-2012 CS Systèmes d'Information
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic long
binomialCoefficient
(int n, int k) Binomial Coefficient, "n choose k
", the number ofk
-element subsets that can be selected from ann
-element set.
-
Constructor Details
-
BinomialCoefficientUtil
public BinomialCoefficientUtil()
-
-
Method Details
-
binomialCoefficient
Binomial Coefficient, "n choose k
", the number ofk
-element subsets that can be selected from ann
-element set.Preconditions:
-
0 <= k <= n
(otherwiseIllegalArgumentException
is thrown) - The result is small enough to fit into a
long
. The largest value ofn
for which all coefficients are< Long.MAX_VALUE
is 66. If the computed value exceedsLong.MAX_VALUE
anArithmeticException
is thrown.
- Parameters:
n
- the size of the setk
- the size of the subsets to be counted- Returns:
n choose k
- Throws:
ArithmeticException
- ifn < 0
ork > n
or the result is too large to be represented by a long integer.
-
-