Class SaddlePointExpansionUtils

java.lang.Object
org.apache.commons.statistics.distribution.SaddlePointExpansionUtils

final class SaddlePointExpansionUtils extends 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 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
    Modifier
    Constructor
    Description
    private
    Forbid construction.
  • Method Summary

    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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TWO_PI

      private static final double TWO_PI
      2 π.
      See Also:
    • ONE_TENTH

      private static final double ONE_TENTH
      1/10.
      See Also:
    • STIRLING_ERROR_THRESHOLD

      private static final int STIRLING_ERROR_THRESHOLD
      The threshold value for switching the method to compute th Stirling error.
      See Also:
    • EXACT_STIRLING_ERRORS

      private static final double[] EXACT_STIRLING_ERRORS
      Exact 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:

      1. 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:

      1. 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)).