papaya
Class Gamma

java.lang.Object
  extended by papaya.Gamma
All Implemented Interfaces:
PapayaConstants

public class Gamma
extends Object
implements PapayaConstants

Gamma and Beta functions.

Implementation: The code is mostly adapted from the CERN Jet Java libraries, which in turn was adapted from the Cephes Mathematical Library. As far a as I can tell, Stephen L. Moshier wrote the original C++ code for CEPHES (1989, moshier@na-net.ornl.gov) and Wolfgang Hoschek (at CERN, hats off to you mate!) then adapted it for the Java platform, making some significant changes along the way.


Field Summary
 
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
 
Method Summary
static float beta(double a, double b)
          Returns the beta function of the arguments.
static double gamma(double x)
          Returns the Gamma function of the argument, Γ(x)
static double incompleteBeta(double aa, double bb, double xx)
          Returns the Incomplete Beta Function evaluated from zero to xx; formerly named ibeta.
static double incompleteBetaInverse(double aa, double bb, double yy0)
          Returns the inverse of the incomplete Beta integral.
static double incompleteGamma(double a, double x)
          Returns the Incomplete Gamma function; formerly named igamma.
static double incompleteGammaComplement(double a, double x)
          Returns the Complemented Incomplete Gamma function; formerly named igamc.
static double logGamma(double x)
          Returns the natural logarithm of the gamma function; formerly named lgamma.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

beta

public static float beta(double a,
                         double b)
                  throws ArithmeticException
Returns the beta function of the arguments.
 
 beta( a, b )  = Γ(a) * Γ(b) ) Γ(a+b)

 

Throws:
ArithmeticException

gamma

public static double gamma(double x)
                    throws ArithmeticException
Returns the Gamma function of the argument, Γ(x)

Throws:
ArithmeticException

incompleteBeta

public static double incompleteBeta(double aa,
                                    double bb,
                                    double xx)
                             throws ArithmeticException
Returns the Incomplete Beta Function evaluated from zero to xx; formerly named ibeta.

Parameters:
aa - the alpha parameter of the beta distribution.
bb - the beta parameter of the beta distribution.
xx - the integration end point.
Throws:
ArithmeticException

incompleteBetaInverse

public static double incompleteBetaInverse(double aa,
                                           double bb,
                                           double yy0)
Returns the inverse of the incomplete Beta integral. That is, given y, the function finds x such that
  incompleteBeta( a, b, x ) = y.
The routine performs interval halving until incompleteBeta(a,b,x) - y = 0, to within roughly 10^-13 of the true solution. If this precision is not reached, the method returns the current approximation of x, and prints a warning statement specifying the current error. Typically, this is on the order of 10^-12.

Parameters:
aa - the alpha parameter of the beta distribution.
bb - the beta parameter of the beta distribution.
yy0 - the value for which to solve for the corresponding x in the incomplete Beta integral.
Returns:
the value x such that incompleteBeta( a, b, x ) = y.

incompleteGamma

public static double incompleteGamma(double a,
                                     double x)
                              throws ArithmeticException
Returns the Incomplete Gamma function; formerly named igamma.

Parameters:
a - the parameter of the gamma distribution.
x - the integration end point.
Throws:
ArithmeticException

incompleteGammaComplement

public static double incompleteGammaComplement(double a,
                                               double x)
                                        throws ArithmeticException
Returns the Complemented Incomplete Gamma function; formerly named igamc.

Parameters:
a - the parameter of the gamma distribution.
x - the integration start point.
Throws:
ArithmeticException

logGamma

public static double logGamma(double x)
                       throws ArithmeticException
Returns the natural logarithm of the gamma function; formerly named lgamma.

Throws:
ArithmeticException


Processing library papaya by Adila Faruk. (C) 2014