public class Gamma
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static double |
MAXGAM
Maximum value for which gamma which can be computed.
|
Modifier | Constructor and Description |
---|---|
protected |
Gamma()
Make class non-instantiable but inheritable.
|
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.
|
public static final double MAXGAM
public static double gamma(double x)
x
- Value for which Gamma is to be computed.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.
public static double logGamma(double y)
y
- Gamma distribution parameter.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.
public static double incompleteGamma(double x, double alpha, int dPrec, int maxIter) throws java.lang.IllegalArgumentException
x
- Gamma distribution valuealpha
- Shape parameterdPrec
- Digits of precision desired (1 < dPrec < Constants.MAXPREC)maxIter
- Maximum number of iterations allowedjava.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.
public static double incompleteGamma(double x, double alpha) throws java.lang.IllegalArgumentException
x
- Gamma distribution valuealpha
- Shape parameterjava.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.