Package org.apache.commons.numbers.gamma
Class Digamma
- java.lang.Object
-
- org.apache.commons.numbers.gamma.Digamma
-
public final class Digamma extends java.lang.Object
Digamma function.It is defined as the logarithmic derivative of the \( \Gamma \) (
Gamma
) function: \( \frac{d}{dx}(\ln \Gamma(x)) = \frac{\Gamma^\prime(x)}{\Gamma(x)} \).- See Also:
Gamma
-
-
Constructor Summary
Constructors Modifier Constructor Description private
Digamma()
Private constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
value(double x)
Computes the digamma function.
-
-
-
Field Detail
-
GAMMA
private static final double GAMMA
- See Also:
- Constant Field Values
-
C_LIMIT
private static final double C_LIMIT
C limit.- See Also:
- Constant Field Values
-
S_LIMIT
private static final double S_LIMIT
S limit.- See Also:
- Constant Field Values
-
F_M1_12
private static final double F_M1_12
Fraction.- See Also:
- Constant Field Values
-
F_1_120
private static final double F_1_120
Fraction.- See Also:
- Constant Field Values
-
F_M1_252
private static final double F_M1_252
Fraction.- See Also:
- Constant Field Values
-
-
Method Detail
-
value
public static double value(double x)
Computes the digamma function. This is an independently written implementation of the algorithm described in Jose Bernardo, Algorithm AS 103: Psi (Digamma) Function, Applied Statistics, 1976. A reflection formula is incorporated to improve performance on negative values. Some of the constants have been changed to increase accuracy at the moderate expense of run-time. The result should be accurate to within1e-8
. relative tolerance for0 < x < 1e-5
and within1e-8
absolute tolerance otherwise.- Parameters:
x
- Argument.- Returns:
- digamma(x) to within
1e-8
relative or absolute error whichever is larger.
-
-