Gamma
Package: Libraries.Compute.Statistics.Distributions · Inherits from: Libraries.Language.Object
This class, ported from Apache Commons, is an implementation of the Gamma Distribution. More information can be found here: https://en.wikipedia.org/wiki/Gamma_distribution
Variables
number DEFAULT_EPSILON
Actions
Gamma(number x)
* The constant {@code C12} defined in {@code DGAM1}.
Parameters
xnumber
Returns
number
InvGamma1pm1(number x)
* From the recurrence relation * Gamma(x) = (x - 1) * ... * (x - n) * Gamma(x - n), * then * Gamma(t) = 1 / [1 + invGamma1pm1(t - 1)], * where t = x - n. This means that t must satisfy * -0.5 <= t - 1 <= 1.5.
Parameters
xnumber
Returns
number
Lanczos(number x)
* From the reflection formula * Gamma(x) * Gamma(1 - x) * sin(pi * x) = pi, * and the recurrence relation * Gamma(1 - x) = -x * Gamma(-x), * it is found * Gamma(x) = -pi / [x * sin(pi * x) * Gamma(-x)].
Parameters
xnumber
Returns
number
LogGamma(number x)
Computes the function ln(Gamma(x)). This is adapted from Apache Commons. The implementation is based on:
- Gamma Function, equation (28).
- Lanczos Approximation, equations (1) through (5).
- Paul Godfrey, A note on the computation of the convergent Lanczos complex Gamma approximation
Parameters
xnumber: the value.
Returns
number: the log gamma function ln(Gamma(x))
LogGamma1p(number x)
* From the recurrence relation * Gamma(x) = Gamma(x + n + 1) / [x * (x + 1) * ... * (x + n)] * then * Gamma(x + n + 1) = 1 / [1 + invGamma1pm1(x + n)], * which requires -0.5 <= x + n <= 1.5.
Parameters
xnumber
Returns
number
RegularizedGammaP(number a, number x)
Returns the regularized gamma function P(a, x). The action is ported from Apache Commons. This uses the default epsilon (error) and the maximum number of iterations is the largest possible integer.
Parameters
anumber: the a parameter.xnumber: the value.
Returns
number: the regularized gamma function P(a, x)
RegularizedGammaP(number a, number x, number epsilon, integer maxIterations)
Returns the regularized gamma function P(a, x). The action is ported from Apache Commons The implementation of this method is based on:
- Regularized Gamma Function, equation (1)
- Incomplete Gamma Function, equation (4).
- Confluent Hypergeometric Function of the First Kind, equation (1).
Parameters
anumber: the a parameter.xnumber: the value.epsilonnumber: When the absolute value of the nth item in the series is less than epsilon the approximation ceases to calculate further elements in the series.maxIterationsinteger: Maximum number of "iterations" to complete.
Returns
number: the regularized gamma function P(a, x)
RegularizedGammaQ(number a, number x)
Returns the regularized gamma function Q(a, x) = 1 - P(a, x). This is adapted from Apache Commons.
Parameters
anumber: the a parameter.xnumber: the value.
Returns
number: the regularized gamma function P(a, x)
RegularizedGammaQ(number a, number x, number epsilon, integer maxIterations)
Returns the regularized gamma function Q(a, x) = 1 - P(a, x). This is adapted from Apache Commons. The implementation of this method is based on:
- Regularized Gamma Function, equation (1).
- Regularized incomplete gamma function: Continued fraction representations (formula 06.08.10.0003)
Parameters
anumber: the a parameter.xnumber: the value.epsilonnumber: When the absolute value of the nth item in the series is less than epsilon the approximation ceases to calculate further elements in the series.maxIterationsinteger: Maximum number of "iterations" to complete.
Returns
number: the regularized gamma function P(a, x)