Class SaddlePointExpansionUtils
- java.lang.Object
-
- org.apache.commons.statistics.distribution.SaddlePointExpansionUtils
-
final class SaddlePointExpansionUtils extends java.lang.Object
Utility class used by various distributions to accurately compute their respective probability mass functions. The implementation for this class is based on the Catherine Loader's dbinom routines. This class is not intended to be called directly.
-
-
Field Summary
Fields Modifier and Type Field Description private static double[]
EXACT_STIRLING_ERRORS
Exact Stirling expansion error for certain values.private static double
ONE_TENTH
1/10.private static int
STIRLING_ERROR_THRESHOLD
The threshold value for switching the method to compute th Stirling error.private static double
TWO_PI
2 π.
-
Constructor Summary
Constructors Modifier Constructor Description private
SaddlePointExpansionUtils()
Forbid construction.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static double
getDeviancePart(int x, double mu)
A part of the deviance portion of the saddle point approximation.(package private) static double
getStirlingError(int z)
Compute the error of Stirling's series at the given value.(package private) static double
logBinomialProbability(int x, int n, double p, double q)
Compute the logarithm of the PMF for a binomial distribution using the saddle point expansion.
-
-
-
Field Detail
-
TWO_PI
private static final double TWO_PI
2 π.- See Also:
- Constant Field Values
-
ONE_TENTH
private static final double ONE_TENTH
1/10.- See Also:
- Constant Field Values
-
STIRLING_ERROR_THRESHOLD
private static final int STIRLING_ERROR_THRESHOLD
The threshold value for switching the method to compute th Stirling error.- See Also:
- Constant Field Values
-
EXACT_STIRLING_ERRORS
private static final double[] EXACT_STIRLING_ERRORS
Exact Stirling expansion error for certain values.
-
-
Method Detail
-
getStirlingError
static double getStirlingError(int z)
Compute the error of Stirling's series at the given value.References:
- Eric W. Weisstein. "Stirling's Series." From MathWorld--A Wolfram Web Resource. https://mathworld.wolfram.com/StirlingsSeries.html
Note: This function has been modified for integer
z
.- Parameters:
z
- Value at which the function is evaluated.- Returns:
- the Stirling's series error.
-
getDeviancePart
static double getDeviancePart(int x, double mu)
A part of the deviance portion of the saddle point approximation.References:
- Catherine Loader (2000). "Fast and Accurate Computation of Binomial Probabilities.". http://www.herine.net/stat/papers/dbinom.pdf
Note: This function has been modified for integer
x
.- Parameters:
x
- Value at which the function is evaluated.mu
- Average.- Returns:
- a part of the deviance.
-
logBinomialProbability
static double logBinomialProbability(int x, int n, double p, double q)
Compute the logarithm of the PMF for a binomial distribution using the saddle point expansion.- Parameters:
x
- Value at which the probability is evaluated.n
- Number of trials.p
- Probability of success.q
- Probability of failure (1 - p).- Returns:
- log(p(x)).
-
-