Header menu logo FSharp.Stats

Gamma Module

 Approximations for the gamma function and related functions.

 The gamma function (represented by Γ, the capital letter gamma from the Greek alphabet) is one commonly used extension 
 of the factorial function to complex numbers:

 Γ(x) = (x-1)!

The gamma function is defined for all complex numbers except the non-positive integers.

Functions and values

Function or value Description

_gamma z

Full Usage: _gamma z

Parameters:
    z : ^T - The function input for approximating Γ(z)

Returns: ^T
Modifiers: inline
Type parameters: ^T

Computes an approximation of the real value of the gamma function using the Lanczos Coefficients described in Numerical Recipes (Press et al)

The caller is responsible to handle edge cases such as nan, infinity, and -infinity in the input

z : ^T

The function input for approximating Γ(z)

Returns: ^T

_gammaLn z

Full Usage: _gammaLn z

Parameters:
    z : ^T - The function input for approximating ln(Γ(z))

Returns: ^T
Modifiers: inline
Type parameters: ^T

Computes an approximation of the real value of the log gamma function using the Lanczos Coefficients described in Numerical Recipes (Press et al)

The caller is responsible to handle edge cases such as nan, infinity, and -infinity in the input

z : ^T

The function input for approximating ln(Γ(z))

Returns: ^T

digamma x

Full Usage: digamma x

Parameters:
    x : ^T

Returns: ^T
Modifiers: inline
Type parameters: ^T

Full digamma function ψ(x),

x : ^T
Returns: ^T

digammaPositive x

Full Usage: digammaPositive x

Parameters:
    x : ^T - The input value (must be > 1).

Returns: ^T The value of the digamma function ψ(x).
Modifiers: inline
Type parameters: ^T

Optimized digamma function for x > 1. Skips reflection and tan-based correction. Use when x is guaranteed to be greater than 1.

x : ^T

The input value (must be > 1).

Returns: ^T

The value of the digamma function ψ(x).

gamma z

Full Usage: gamma z

Parameters:
    z : 'T - The function input for approximating Γ(z)

Returns: 'T
Modifiers: inline
Type parameters: 'T

Computes an approximation of the real value of the gamma function using the Lanczos Coefficients described in Numerical Recipes (Press et al)

Edge cases in the input (nan, infinity, and -infinity) are catched and handled. This might be slower than the unchecked version `_gamma` but does not require input sanitation to get expected results for these cases.

z : 'T

The function input for approximating Γ(z)

Returns: 'T

gammaLn z

Full Usage: gammaLn z

Parameters:
    z : 'T - The function input for approximating ln(Γ(z))

Returns: 'T
Modifiers: inline
Type parameters: 'T

Computes an approximation of the real value of the log gamma function using the Lanczos Coefficients described in Numerical Recipes (Press et al)

Edge cases in the input (nan, infinity, and -infinity) are catched and handled. This might be slower than the unchecked version `_gamma` but does not require input sanitation to get expected results for these cases.

z : 'T

The function input for approximating ln(Γ(z))

Returns: 'T

gammpapprox a x psig

Full Usage: gammpapprox a x psig

Parameters:
    a : ^T
    x : ^T
    psig : bool

Returns: ^T
Modifiers: inline
Type parameters: ^T
a : ^T
x : ^T
psig : bool
Returns: ^T

gcf a x

Full Usage: gcf a x

Parameters:
    a : ^T
    x : ^T

Returns: ^T
Modifiers: inline
Type parameters: ^T
a : ^T
x : ^T
Returns: ^T

gser a x

Full Usage: gser a x

Parameters:
    a : ^T
    x : ^T

Returns: ^T
Modifiers: inline
Type parameters: ^T
a : ^T
x : ^T
Returns: ^T

lowerIncomplete a x

Full Usage: lowerIncomplete a x

Parameters:
    a : 'T -
    x : 'T -

Returns: 'T
Modifiers: inline
Type parameters: 'T

Returns the lower incomplete gamma function
gamma(a,x) = int(exp(-t)t^(a-1),t=0..x) for real a > 0, x > 0.

a : 'T

x : 'T

Returns: 'T

Example

lowerIncompleteRegularized a x

Full Usage: lowerIncompleteRegularized a x

Parameters:
    a : 'T
    x : 'T

Returns: 'T
Modifiers: inline
Type parameters: 'T

Returns the incomplete gamma function P(a,X) (regularized gamma)

a : 'T
x : 'T
Returns: 'T

maximum

Full Usage: maximum

Returns: float

Maximum gamma

Returns: float

trigamma x

Full Usage: trigamma x

Parameters:
    x : float

Returns: float

Trigamma function.

This code has been adapted from the FORTRAN77 and subsequent C code by B. E. Schneider and John Burkardt. The code had been made public under the GNU LGPL license.

x : float
Returns: float

upperIncomplete a x

Full Usage: upperIncomplete a x

Parameters:
    a : 'T -
    x : 'T -

Returns: 'T
Modifiers: inline
Type parameters: 'T

Returns the upper incomplete gamma function
Gamma(a,x) = int(exp(-t)t^(a-1),t=0..x) for real a > 0, x > 0.

a : 'T

x : 'T

Returns: 'T

Example

upperIncompleteRegularized a x

Full Usage: upperIncompleteRegularized a x

Parameters:
    a : 'T
    x : 'T

Returns: 'T
Modifiers: inline
Type parameters: 'T

Returns the incomplete gamma function Q(a,X) = 1 - P(a,X) (regularized gamma)

a : 'T
x : 'T
Returns: 'T

Type something to start searching.