public class Gamma
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static double |
GAMMA
|
Modifier and Type | Method and Description |
---|---|
static double |
digamma(double x)
Computes the digamma function of x.
|
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).
|
static double |
trigamma(double x)
Computes the trigamma function of x.
|
public static final double GAMMA
public static double logGamma(double x)
x
- the value.public static double regularizedGammaP(double a, double x) throws MathException
a
- the a parameter.x
- the value.MathException
- if the algorithm fails to converge.public static double regularizedGammaP(double a, double x, double epsilon, int maxIterations) throws MathException
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.MathException
- if the algorithm fails to converge.public static double regularizedGammaQ(double a, double x) throws MathException
a
- the a parameter.x
- the value.MathException
- if the algorithm fails to converge.public static double regularizedGammaQ(double a, double x, double epsilon, int maxIterations) throws MathException
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.MathException
- if the algorithm fails to converge.public static double digamma(double x)
Computes the digamma function of x.
This is an independently written implementation of the algorithm described in Jose Bernardo, Algorithm AS 103: Psi (Digamma) Function, Applied Statistics, 1976.
Some of the constants have been changed to increase accuracy at the moderate expense of run-time. The result should be accurate to within 10^-8 absolute tolerance for x >= 10^-5 and within 10^-8 relative tolerance for x > 0.
Performance for large negative values of x will be quite expensive (proportional to |x|). Accuracy for negative values of x should be about 10^-8 absolute for results less than 10^5 and 10^-8 relative for results larger than that.
x
- the argumentpublic static double trigamma(double x)
Computes the trigamma function of x. This function is derived by taking the derivative of the implementation of digamma.
x
- the argumentdigamma(double)
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"