Documentation

GammaBase
in package

AbstractYes

Table of Contents

Constants

EPS  = 2.22E-16
LG_C  = [-0.001910444077728, 0.0008417138778129501, -0.0005952379913043012, 0.0007936507935003503, -0.0027777777777776816, 0.08333333333333333, 0.0057083835261]
LG_D1  = -0.5772156649015329
LG_D2  = 0.42278433509846713
LG_D4  = 1.791759469228055
LG_FRTBIG  = 2.25E+76
LG_P1  = [4.945235359296727, 201.8112620856775, 2290.8383738313464, 11319.672059033808, 28557.246356716354, 38484.962284437934, 26377.487876241954, 7225.813979700288]
LG_P2  = [4.974607845568932, 542.4138599891071, 15506.93864978365, 184793.29044456323, 1088204.7694688288, 3338152.96798703, 5106661.678927353, 3074109.0548505397]
LG_P4  = [14745.0216605994, 2426813.3694867045, 121475557.40450932, 2663432449.630977, 29403789566.34554, 170266573776.5399, 492612579337.7431, 560625185622.3951]
LG_Q1  = [67.48212550303778, 1113.3323938571993, 7738.757056935398, 27639.870744033407, 54993.102062261576, 61611.22180066002, 36351.2759150194, 8785.536302431014]
LG_Q2  = [183.03283993705926, 7765.049321445006, 133190.38279660742, 1136705.8213219696, 5267964.117437947, 13467014.543111017, 17827365.303532742, 9533095.591844354]
LG_Q4  = [2690.5301758708993, 639388.5654300093, 41355999.30241388, 1120872109.616148, 14886137286.788137, 101680358627.24382, 341747634550.73773, 446315818741.9713]
LOG_GAMMA_X_MAX_VALUE  = 2.55E+305
MAX_ITERATIONS  = 256
MAX_VALUE  = 1.2E+308
PNT68  = 0.6796875
SQRT2PI  = 2.5066282746310007

Properties

$logGammaCacheResult  : float
$logGammaCacheX  : float

Methods

gammaValue()  : float
incompleteGamma()  : float
logGamma()  : float
logGamma function.
calculateDistribution()  : float
calculateInverse()  : float|string
logGamma3()  : float
logGamma4()  : float
logGamma1()  : float
logGamma2()  : float

Constants

LG_C

private mixed LG_C = [-0.001910444077728, 0.0008417138778129501, -0.0005952379913043012, 0.0007936507935003503, -0.0027777777777776816, 0.08333333333333333, 0.0057083835261]

LG_D1

private mixed LG_D1 = -0.5772156649015329

LG_D2

private mixed LG_D2 = 0.42278433509846713

LG_D4

private mixed LG_D4 = 1.791759469228055

LG_FRTBIG

private mixed LG_FRTBIG = 2.25E+76

LG_P1

private mixed LG_P1 = [4.945235359296727, 201.8112620856775, 2290.8383738313464, 11319.672059033808, 28557.246356716354, 38484.962284437934, 26377.487876241954, 7225.813979700288]

LG_P2

private mixed LG_P2 = [4.974607845568932, 542.4138599891071, 15506.93864978365, 184793.29044456323, 1088204.7694688288, 3338152.96798703, 5106661.678927353, 3074109.0548505397]

LG_P4

private mixed LG_P4 = [14745.0216605994, 2426813.3694867045, 121475557.40450932, 2663432449.630977, 29403789566.34554, 170266573776.5399, 492612579337.7431, 560625185622.3951]

LG_Q1

private mixed LG_Q1 = [67.48212550303778, 1113.3323938571993, 7738.757056935398, 27639.870744033407, 54993.102062261576, 61611.22180066002, 36351.2759150194, 8785.536302431014]

LG_Q2

private mixed LG_Q2 = [183.03283993705926, 7765.049321445006, 133190.38279660742, 1136705.8213219696, 5267964.117437947, 13467014.543111017, 17827365.303532742, 9533095.591844354]

LG_Q4

private mixed LG_Q4 = [2690.5301758708993, 639388.5654300093, 41355999.30241388, 1120872109.616148, 14886137286.788137, 101680358627.24382, 341747634550.73773, 446315818741.9713]

LOG_GAMMA_X_MAX_VALUE

private mixed LOG_GAMMA_X_MAX_VALUE = 2.55E+305

MAX_ITERATIONS

private mixed MAX_ITERATIONS = 256

MAX_VALUE

private mixed MAX_VALUE = 1.2E+308

SQRT2PI

private mixed SQRT2PI = 2.5066282746310007

Properties

$logGammaCacheResult

private static float $logGammaCacheResult = 0.0

$logGammaCacheX

private static float $logGammaCacheX = 0.0

Methods

gammaValue()

public static gammaValue(float $value) : float
Parameters
$value : float
Return values
float

incompleteGamma()

public static incompleteGamma(float $a, float $x) : float
Parameters
$a : float
$x : float
Return values
float

logGamma()

logGamma function.

public static logGamma(float $x) : float

Original author was Jaco van Kooten. Ported to PHP by Paul Meagher.

The natural logarithm of the gamma function.
Based on public domain NETLIB (Fortran) code by W. J. Cody and L. Stoltz
Applied Mathematics Division
Argonne National Laboratory
Argonne, IL 60439

References:

  1. W. J. Cody and K. E. Hillstrom, 'Chebyshev Approximations for the Natural Logarithm of the Gamma Function,' Math. Comp. 21, 1967, pp. 198-203.
  2. K. E. Hillstrom, ANL/AMD Program ANLC366S, DGAMMA/DLGAMA, May, 1969.
  3. Hart, Et. Al., Computer Approximations, Wiley and sons, New York, 1968.

From the original documentation:

This routine calculates the LOG(GAMMA) function for a positive real argument X. Computation is based on an algorithm outlined in references 1 and 2. The program uses rational functions that theoretically approximate LOG(GAMMA) to at least 18 significant decimal digits. The approximation for X > 12 is from reference 3, while approximations for X < 12.0 are similar to those in reference 1, but are unpublished. The accuracy achieved depends on the arithmetic system, the compiler, the intrinsic functions, and proper selection of the machine-dependent constants.

Error returns:
The program returns the value XINF for X .LE. 0.0 or when overflow would occur. The computation is believed to be free of underflow and overflow.

Parameters
$x : float
Tags
version
1.1
author

Jaco van Kooten

Return values
float

MAX_VALUE for x < 0.0 or when overflow would occur, i.e. x > 2.55E305

calculateDistribution()

protected static calculateDistribution(float $value, float $a, float $b, bool $cumulative) : float
Parameters
$value : float
$a : float
$b : float
$cumulative : bool
Return values
float

calculateInverse()

protected static calculateInverse(float $probability, float $alpha, float $beta) : float|string
Parameters
$probability : float
$alpha : float
$beta : float
Return values
float|string

logGamma3()

protected static logGamma3(float $y) : float
Parameters
$y : float
Return values
float

logGamma4()

protected static logGamma4(float $y) : float
Parameters
$y : float
Return values
float

logGamma1()

private static logGamma1(float $y) : float
Parameters
$y : float
Return values
float

logGamma2()

private static logGamma2(float $y) : float
Parameters
$y : float
Return values
float

        
On this page

Search results