edu.northwestern.at.utils.math.distributions

## Class Gamma

- java.lang.Object
- - edu.northwestern.at.utils.math.distributions.Gamma

-     public class Gamma
      extends java.lang.Object

  Gamma distribution functions.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static double` | `MAXGAM` Maximum value for which gamma which can be computed.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `Gamma()` Make class non-instantiable but inheritable.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static double` | `gamma(double x)` Gamma function.
    `static double` | `incompleteGamma(double x, double alpha)` Cumulative probability density function for the incomplete gamma function.
    `static double` | `incompleteGamma(double x, double alpha, int dPrec, int maxIter)` Cumulative probability density function for the incomplete gamma function.
    `static double` | `logGamma(double y)` Calculate log of Gamma function.

    - ### Methods inherited from class java.lang.Object

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

- - ### Field Detail

    - #### MAXGAM

          public static final double MAXGAM

      Maximum value for which gamma which can be computed.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Gamma

          protected Gamma()

      Make class non-instantiable but inheritable.

  - ### Method Detail

    - #### gamma

          public static double gamma(double x)

      Gamma function.
      Parameters:
        `x` - Value for which Gamma is to be computed.
      Returns:
        Value of gamma function if computable. The value Double.POSITIVE_INFINITY is returned for bad values of x or when overflow would occur.

        The method used is presented in "An Overview of Software Development for Special Functions" by W. J. Cody in Lecture Notes in Mathematics, 506, Numerical Analysis Dundee, 1975, G. A. Watson (ed.), Springer Verlag, Berlin, 1976.

        Also see Hart et al, "Computer Approximations", Wiley(1968), p. 130F.

        This java code is a fairly straightforward translation of the freely available Fortran function GAMMA by Cody and Stolz.

    - #### logGamma

          public static double logGamma(double y)

      Calculate log of Gamma function.
      Parameters:
        `y` - Gamma distribution parameter.
      Returns:
        Log gamma for specified parameter. The value Double.POSITIVE_INFINITY is returned for y <= 0.0 or when overflow would occur.

        Minimax polynomial approximations are used over the intervals [-inf,0], [0,.5], [.5,1.5], [1.5,4.0], [4.0,12.0], [12.0,+inf].

        See Hart et al, "Computer Approximations", Wiley(1968), p. 130F, and also Cody and Hillstrom, "Chebyshev approximations for the natural logarithm of the Gamma function", Mathematics of Computation, 21, April, 1967, P. 198F.

        The minimax coefficients for y > 12 come from Hart et al. The other coefficients come from unpublished work by W. J. Cody and L. Stoltz at Argonne National Laboratory. This java code is a fairly straightforward translation of the freely available Fortran function ALGAMA by Cody and Stolz.

    - #### incompleteGamma

          public static double incompleteGamma(double x,
                               double alpha,
                               int dPrec,
                               int maxIter)
                                        throws java.lang.IllegalArgumentException

      Cumulative probability density function for the incomplete gamma function.
      Parameters:
        `x` - Gamma distribution value
        `alpha` - Shape parameter
        `dPrec` - Digits of precision desired (1 < dPrec < Constants.MAXPREC)
        `maxIter` - Maximum number of iterations allowed
      Returns:
        Cumulative probability density function value
      Throws:
        `java.lang.IllegalArgumentException` - if x < 0 or alpha <= 0

        Either an infinite series summation or a continued fraction approximation is used, depending upon the argument range. See Bhattacharjee GP (1970) The incomplete gamma integral. Applied Statistics, 19: 285-287 (AS32) . The result is accurate to about 14 decimal digits.

    - #### incompleteGamma

          public static double incompleteGamma(double x,
                               double alpha)
                                        throws java.lang.IllegalArgumentException

      Cumulative probability density function for the incomplete gamma function.
      Parameters:
        `x` - Gamma distribution value
        `alpha` - Shape parameter
      Returns:
        Cumulative probability density function value
      Throws:
        `java.lang.IllegalArgumentException` - if x < 0 or alpha <= 0

        Either an infinite series summation or a continued fraction approximation is used, depending upon the argument range. See Bhattacharjee GP (1970) The incomplete gamma integral. Applied Statistics, 19: 285-287 (AS32) . The result is accurate to about 14 decimal digits.