Class SaddlePointExpansionUtils
java.lang.Object
org.apache.commons.statistics.distribution.SaddlePointExpansionUtils
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
FieldsModifier and TypeFieldDescriptionprivate static final double[]
Exact Stirling expansion error for certain values.private static final double
1/10.private static final int
The threshold value for switching the method to compute th Stirling error.private static final double
2 π. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(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 Details
-
TWO_PI
private static final double TWO_PI2 π.- See Also:
-
ONE_TENTH
private static final double ONE_TENTH1/10.- See Also:
-
STIRLING_ERROR_THRESHOLD
private static final int STIRLING_ERROR_THRESHOLDThe threshold value for switching the method to compute th Stirling error.- See Also:
-
EXACT_STIRLING_ERRORS
private static final double[] EXACT_STIRLING_ERRORSExact Stirling expansion error for certain values.
-
-
Constructor Details
-
SaddlePointExpansionUtils
private SaddlePointExpansionUtils()Forbid construction.
-
-
Method Details
-
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)).
-