Package htsjdk.variant.utils
Class BinomialCoefficientUtil
- java.lang.Object
-
- htsjdk.variant.utils.BinomialCoefficientUtil
-
public class BinomialCoefficientUtil extends Object
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 Constructor Description BinomialCoefficientUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longbinomialCoefficient(int n, int k)Binomial Coefficient, "n choose k", the number ofk-element subsets that can be selected from ann-element set.
-
-
-
Method Detail
-
binomialCoefficient
public static long binomialCoefficient(int n, int k) throws ArithmeticExceptionBinomial Coefficient, "n choose k", the number ofk-element subsets that can be selected from ann-element set.Preconditions:
-
0 <= k <= n(otherwiseIllegalArgumentExceptionis thrown) - The result is small enough to fit into a
long. The largest value ofnfor which all coefficients are< Long.MAX_VALUEis 66. If the computed value exceedsLong.MAX_VALUEanArithmeticExceptionis thrown.
- Parameters:
n- the size of the setk- the size of the subsets to be counted- Returns:
n choose k- Throws:
ArithmeticException- ifn < 0ork > nor the result is too large to be represented by a long integer.
-
-
-