# 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

Modifier and Type
Method
Description
`static long`
`binomialCoefficient(int n, int k)`
Binomial Coefficient, "`n choose k`", the number of `k`-element subsets that can be selected from an `n`-element set.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### BinomialCoefficientUtil

public BinomialCoefficientUtil()

## Method Details

### binomialCoefficient

public static long binomialCoefficient(int n, int k) throws ArithmeticException
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)
- The result is small enough to fit into a `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.

Parameters:
  `n` - the size of the set
  `k` - the size of the subsets to be counted
Returns:
  `n choose k`
Throws:
  `ArithmeticException` - if `n < 0` or `k > n` or the result is too large to be represented by a long integer.