## org.apache.mahout.math.jet.math
Class Arithmetic

    java.lang.Object
      org.apache.mahout.math.jet.math.Arithmetic

    public final class Arithmetic

extends Object

Arithmetic functions.

Method Summary
`static double` `binomial(long n, long k)` Efficiently returns the binomial coefficient, often also referred to as "n over k" or "n choose k".
`static double` `logFactorial(int k)` Returns `log(k!)`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### binomial

    public static double binomial(long n,
                                  long k)

  Efficiently returns the binomial coefficient, often also referred to as "n over k" or "n choose k". The binomial coefficient is defined as
  - k<0`: `0`.`
  - k==0 || k==n`: `1`.`
  - k==1 || k==n-1`: `n`.`
  - else: `(n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )`.

  Returns:
    the binomial coefficient.

### logFactorial

    public static double logFactorial(int k)

  Returns `log(k!)`. Tries to avoid overflows. For `k<30` simply looks up a table in O(1). For `k>=30` uses stirlings approximation.

  Parameters:
    `k` - must hold `k >= 0`.

Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.