org.apache.commons.math.special
Class Gamma

java.lang.Object
  extended by org.apache.commons.math.special.Gamma
All Implemented Interfaces:
java.io.Serializable

public class Gamma
extends java.lang.Object
implements java.io.Serializable

This is a utility class that provides computation methods related to the Gamma family of functions.

Version:
$Revision: 233121 $ $Date: 2005-08-16 21:41:02 -0700 (Tue, 16 Aug 2005) $
See Also:
Serialized Form

Field Summary
private static double DEFAULT_EPSILON
          Maximum allowed numerical error.
private static double HALF_LOG_2_PI
          Avoid repeated computation of log of 2 PI in logGamma
private static double[] lanczos
          Lanczos coefficients
 
Constructor Summary
private Gamma()
          Default constructor.
 
Method Summary
static double logGamma(double x)
          Returns the natural logarithm of the gamma function Γ(x).
static double regularizedGammaP(double a, double x)
          Returns the regularized gamma function P(a, x).
static double regularizedGammaP(double a, double x, double epsilon, int maxIterations)
          Returns the regularized gamma function P(a, x).
static double regularizedGammaQ(double a, double x)
          Returns the regularized gamma function Q(a, x) = 1 - P(a, x).
static double regularizedGammaQ(double a, double x, double epsilon, int maxIterations)
          Returns the regularized gamma function Q(a, x) = 1 - P(a, x).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_EPSILON

private static final double DEFAULT_EPSILON
Maximum allowed numerical error.

See Also:
Constant Field Values

lanczos

private static double[] lanczos
Lanczos coefficients


HALF_LOG_2_PI

private static final double HALF_LOG_2_PI
Avoid repeated computation of log of 2 PI in logGamma

Constructor Detail

Gamma

private Gamma()
Default constructor. Prohibit instantiation.

Method Detail

logGamma

public static double logGamma(double x)
Returns the natural logarithm of the gamma function Γ(x). The implementation of this method is based on:

Parameters:
x - the value.
Returns:
log(Γ(x))

regularizedGammaP

public static double regularizedGammaP(double a,
                                       double x)
                                throws MathException
Returns the regularized gamma function P(a, x).

Parameters:
a - the a parameter.
x - the value.
Returns:
the regularized gamma function P(a, x)
Throws:
MathException - if the algorithm fails to converge.

regularizedGammaP

public static double regularizedGammaP(double a,
                                       double x,
                                       double epsilon,
                                       int maxIterations)
                                throws MathException
Returns the regularized gamma function P(a, x). The implementation of this method is based on:

Parameters:
a - the a parameter.
x - the value.
epsilon - When the absolute value of the nth item in the series is less than epsilon the approximation ceases to calculate further elements in the series.
maxIterations - Maximum number of "iterations" to complete.
Returns:
the regularized gamma function P(a, x)
Throws:
MathException - if the algorithm fails to converge.

regularizedGammaQ

public static double regularizedGammaQ(double a,
                                       double x)
                                throws MathException
Returns the regularized gamma function Q(a, x) = 1 - P(a, x).

Parameters:
a - the a parameter.
x - the value.
Returns:
the regularized gamma function Q(a, x)
Throws:
MathException - if the algorithm fails to converge.

regularizedGammaQ

public static double regularizedGammaQ(double a,
                                       double x,
                                       double epsilon,
                                       int maxIterations)
                                throws MathException
Returns the regularized gamma function Q(a, x) = 1 - P(a, x). The implementation of this method is based on:

Parameters:
a - the a parameter.
x - the value.
epsilon - When the absolute value of the nth item in the series is less than epsilon the approximation ceases to calculate further elements in the series.
maxIterations - Maximum number of "iterations" to complete.
Returns:
the regularized gamma function P(a, x)
Throws:
MathException - if the algorithm fails to converge.