Class SaddlePointExpansion
java.lang.Object
org.apache.commons.math3.distribution.SaddlePointExpansion
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.
References:
- Catherine Loader (2000). "Fast and Accurate Computation of Binomial Probabilities.". http://www.herine.net/stat/papers/dbinom.pdf
- Since:
- 2.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final double[]
exact Stirling expansion error for certain values.private static final double
1/2 * log(2 π). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static double
getDeviancePart
(double x, double mu) A part of the deviance portion of the saddle point approximation.(package private) static double
getStirlingError
(double 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
-
HALF_LOG_2_PI
private static final double HALF_LOG_2_PI1/2 * log(2 π). -
EXACT_STIRLING_ERRORS
private static final double[] EXACT_STIRLING_ERRORSexact Stirling expansion error for certain values.
-
-
Constructor Details
-
SaddlePointExpansion
private SaddlePointExpansion()Default constructor.
-
-
Method Details
-
getStirlingError
static double getStirlingError(double 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. http://mathworld.wolfram.com/StirlingsSeries.html
- Parameters:
z
- the value.- Returns:
- the Striling's series error.
-
getDeviancePart
static double getDeviancePart(double 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
- Parameters:
x
- the x value.mu
- the 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
- the value at which the probability is evaluated.n
- the number of trials.p
- the probability of success.q
- the probability of failure (1 - p).- Returns:
- log(p(x)).
-