edu.northwestern.at.utils.math
Class Factorial

java.lang.Object
  extended by edu.northwestern.at.utils.math.Factorial

public class Factorial
extends java.lang.Object

Defines methods for factorials.


Field Summary
protected static double[] doubleFactorials
           
protected static long[] longFactorials
           
 
Constructor Summary
Factorial()
           
 
Method Summary
static double factorial(int n)
          Compute factorial of an integer.
static double logFactorial(int n)
          Computes the natural log of n factorial.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

longFactorials

protected static final long[] longFactorials

doubleFactorials

protected static final double[] doubleFactorials
Constructor Detail

Factorial

public Factorial()
Method Detail

factorial

public static double factorial(int n)
Compute factorial of an integer.

Parameters:
n - Number for which to compute factorial.
Returns:
n!

logFactorial

public static double logFactorial(int n)
Computes the natural log of n factorial.

Parameters:
n - The number for which the log factorial is desired.
Returns:
The natural log of n! .

We use the LogGamma function to compute log(n!) using the relation:

log(n!) = logGamma( n + 1 )