Class InternalGamma


  • final class InternalGamma
    extends java.lang.Object

    Adapted and stripped down copy of class "org.apache.commons.math4.special.Gamma".

    This is a utility class that provides computation methods related to the Γ (Gamma) family of functions.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static double HALF_LOG_2_PI
      Avoid repeated computation of log of 2 PI in logGamma.
      private static double[] LANCZOS_COEFFICIENTS
      Lanczos coefficients.
      static double LANCZOS_G
      Constant \( g = \frac{607}{128} \) in the Lanczos approximation.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private InternalGamma()
      Class contains only static methods.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static double lanczos​(double x)
      Computes the Lanczos approximation used to compute the gamma function.
      static double logGamma​(double x)
      Computes the function \( \ln \Gamma(x) \) for \( x > 0 \).
      • Methods inherited from class java.lang.Object

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

      • LANCZOS_G

        public static final double LANCZOS_G
        Constant \( g = \frac{607}{128} \) in the Lanczos approximation.
        See Also:
        Constant Field Values
      • LANCZOS_COEFFICIENTS

        private static final double[] LANCZOS_COEFFICIENTS
        Lanczos coefficients.
      • HALF_LOG_2_PI

        private static final double HALF_LOG_2_PI
        Avoid repeated computation of log of 2 PI in logGamma.
    • Constructor Detail

      • InternalGamma

        private InternalGamma()
        Class contains only static methods.
    • Method Detail

      • lanczos

        private static double lanczos​(double x)
        Computes the Lanczos approximation used to compute the gamma function.

        The Lanczos approximation is related to the Gamma function by the following equation \[ \Gamma(x) = \sqrt{2\pi} \, \frac{(g + x + \frac{1}{2})^{x + \frac{1}{2}} \, e^{-(g + x + \frac{1}{2})} \, \mathrm{lanczos}(x)} {x} \] where \(g\) is the Lanczos constant.

        Parameters:
        x - Argument.
        Returns:
        The Lanczos approximation.
        See Also:
        Lanczos Approximation equations (1) through (5), and Paul Godfrey's Note on the computation of the convergent Lanczos complex Gamma approximation