Package org.apache.commons.numbers.gamma
Class LogBeta
java.lang.Object
org.apache.commons.numbers.gamma.LogBeta
Computes \( log_e B(p, q) \).
This class is immutable.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final double[]
The coefficients of the series expansion of the \( \Delta \) function.private static final double
The constant value of ½log 2π.private static final double
The threshold value of 10 where the series expansion of the \( \Delta \) function applies.private static final double
The threshold value of 1000 for algorithm switch.private static final double
The threshold value of 2 for algorithm switch. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static double
deltaMinusDeltaSum
(double a, double b) Returns the value of \( \Delta(b) - \Delta(a + b) \), with \( 0 \leq a \leq b \) and \( b \geq 10 \).private static double
logGammaMinusLogGammaSum
(double a, double b) Returns the value of \( \log ( \Gamma(b) / \Gamma(a + b) ) \) for \( a \geq 0 \) and \( b \geq 10 \).private static double
sumDeltaMinusDeltaSum
(double p, double q) Returns the value of \( \Delta(p) + \Delta(q) - \Delta(p + q) \), with \( p, q \geq 10 \).static double
value
(double p, double q) Returns the value of \( \log B(p, q) \) for \( 0 \leq x \leq 1 \) and \( p, q > 0 \).
-
Field Details
-
TEN
private static final double TENThe threshold value of 10 where the series expansion of the \( \Delta \) function applies.- See Also:
-
TWO
private static final double TWOThe threshold value of 2 for algorithm switch.- See Also:
-
THOUSAND
private static final double THOUSANDThe threshold value of 1000 for algorithm switch.- See Also:
-
HALF_LOG_TWO_PI
private static final double HALF_LOG_TWO_PIThe constant value of ½log 2π.- See Also:
-
DELTA
private static final double[] DELTAThe coefficients of the series expansion of the \( \Delta \) function. This function is defined as follows: \[ \Delta(x) = \log \Gamma(x) - (x - \frac{1}{2}) \log a + a - \frac{1}{2} \log 2\pi, \]See equation (23) in Didonato and Morris (1992). The series expansion, which applies for \( x \geq 10 \), reads
\[ \Delta(x) = \frac{1}{x} \sum_{n = 0}^{14} d_n (\frac{10}{x})^{2 n} \]
-
-
Constructor Details
-
LogBeta
private LogBeta()Private constructor.
-
-
Method Details
-
deltaMinusDeltaSum
private static double deltaMinusDeltaSum(double a, double b) Returns the value of \( \Delta(b) - \Delta(a + b) \), with \( 0 \leq a \leq b \) and \( b \geq 10 \). Based on equations (26), (27) and (28) in Didonato and Morris (1992).- Parameters:
a
- First argument.b
- Second argument.- Returns:
- the value of \( \Delta(b) - \Delta(a + b) \)
- Throws:
IllegalArgumentException
- ifa < 0
ora > b
IllegalArgumentException
- ifb < 10
-
sumDeltaMinusDeltaSum
private static double sumDeltaMinusDeltaSum(double p, double q) Returns the value of \( \Delta(p) + \Delta(q) - \Delta(p + q) \), with \( p, q \geq 10 \). Based on the NSWC Library of Mathematics Subroutines implementation,DBCORR
.- Parameters:
p
- First argument.q
- Second argument.- Returns:
- the value of \( \Delta(p) + \Delta(q) - \Delta(p + q) \).
- Throws:
IllegalArgumentException
- ifp < 10
orq < 10
.
-
value
public static double value(double p, double q) Returns the value of \( \log B(p, q) \) for \( 0 \leq x \leq 1 \) and \( p, q > 0 \). Based on the NSWC Library of Mathematics Subroutines implementation,DBETLN
.- Parameters:
p
- First argument.q
- Second argument.- Returns:
- the value of \( \log B(p, q) \), or
NaN
ifp <= 0
orq <= 0
.
-
logGammaMinusLogGammaSum
private static double logGammaMinusLogGammaSum(double a, double b) Returns the value of \( \log ( \Gamma(b) / \Gamma(a + b) ) \) for \( a \geq 0 \) and \( b \geq 10 \). Based on the NSWC Library of Mathematics Subroutines implementation,DLGDIV
.- Parameters:
a
- First argument.b
- Second argument.- Returns:
- the value of \( \log(\Gamma(b) / \Gamma(a + b) \).
- Throws:
IllegalArgumentException
- ifa < 0
orb < 10
.
-