Documentation

Gamma extends GammaBase
in package
uses ArrayEnabled

Table of Contents

Methods

distribution()  : array<string|int, mixed>|float|string
GAMMADIST.
gamma()  : array<string|int, mixed>|float|string
GAMMA.
gammaValue()  : float
incompleteGamma()  : float
inverse()  : array<string|int, mixed>|float|string
GAMMAINV.
ln()  : array<string|int, mixed>|float|string
GAMMALN.
logGamma()  : float
logGamma function.
calculateDistribution()  : float
calculateInverse()  : float|string
evaluateArrayArguments()  : array<string|int, mixed>
Handles array argument processing when the function accepts multiple arguments, and any of them can be an array argument.
evaluateArrayArgumentsIgnore()  : array<string|int, mixed>
Handles array argument processing when the function accepts multiple arguments, and any of them can be an array argument except for the one specified by ignore.
evaluateArrayArgumentsSubset()  : array<string|int, mixed>
Handles array argument processing when the function accepts multiple arguments, but only the first few (up to limit) can be an array arguments.
evaluateArrayArgumentsSubsetFrom()  : array<string|int, mixed>
Handles array argument processing when the function accepts multiple arguments, but only the last few (from start) can be an array arguments.
evaluateSingleArgumentArray()  : array<string|int, mixed>
Handles array argument processing when the function accepts a single argument that can be an array argument.
logGamma3()  : float
logGamma4()  : float

Methods

distribution()

GAMMADIST.

public static distribution(mixed $value, mixed $a, mixed $b, mixed $cumulative) : array<string|int, mixed>|float|string

Returns the gamma distribution.

Parameters
$value : mixed

Float Value at which you want to evaluate the distribution Or can be an array of values

$a : mixed

Parameter to the distribution as a float Or can be an array of values

$b : mixed

Parameter to the distribution as a float Or can be an array of values

$cumulative : mixed

Boolean value indicating if we want the cdf (true) or the pdf (false) Or can be an array of values

Return values
array<string|int, mixed>|float|string

If an array of numbers is passed as an argument, then the returned result will also be an array with the same dimensions

gamma()

GAMMA.

public static gamma(mixed $value) : array<string|int, mixed>|float|string

Return the gamma function value.

Parameters
$value : mixed

Float value for which we want the probability Or can be an array of values

Return values
array<string|int, mixed>|float|string

The result, or a string containing an error If an array of numbers is passed as an argument, then the returned result will also be an array with the same dimensions

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

inverse()

GAMMAINV.

public static inverse(mixed $probability, mixed $alpha, mixed $beta) : array<string|int, mixed>|float|string

Returns the inverse of the Gamma distribution.

Parameters
$probability : mixed

Float probability at which you want to evaluate the distribution Or can be an array of values

$alpha : mixed

Parameter to the distribution as a float Or can be an array of values

$beta : mixed

Parameter to the distribution as a float Or can be an array of values

Return values
array<string|int, mixed>|float|string

If an array of numbers is passed as an argument, then the returned result will also be an array with the same dimensions

ln()

GAMMALN.

public static ln(mixed $value) : array<string|int, mixed>|float|string

Returns the natural logarithm of the gamma function.

Parameters
$value : mixed

Float Value at which you want to evaluate the distribution Or can be an array of values

Return values
array<string|int, mixed>|float|string

If an array of numbers is passed as an argument, then the returned result will also be an array with the same dimensions

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

evaluateArrayArguments()

Handles array argument processing when the function accepts multiple arguments, and any of them can be an array argument.

protected static evaluateArrayArguments(callable $method, mixed ...$arguments) : array<string|int, mixed>

Example use for: ROUND() or DATE().

Parameters
$method : callable
$arguments : mixed
Return values
array<string|int, mixed>

evaluateArrayArgumentsIgnore()

Handles array argument processing when the function accepts multiple arguments, and any of them can be an array argument except for the one specified by ignore.

protected static evaluateArrayArgumentsIgnore(callable $method, int $ignore, mixed ...$arguments) : array<string|int, mixed>

Example use for: HLOOKUP() and VLOOKUP(), where argument 1 is a matrix that needs to be treated as a database rather than as an array argument.

Parameters
$method : callable
$ignore : int
$arguments : mixed
Return values
array<string|int, mixed>

evaluateArrayArgumentsSubset()

Handles array argument processing when the function accepts multiple arguments, but only the first few (up to limit) can be an array arguments.

protected static evaluateArrayArgumentsSubset(callable $method, int $limit, mixed ...$arguments) : array<string|int, mixed>

Example use for: NETWORKDAYS() or CONCATENATE(), where the last argument is a matrix (or a series of values) that need to be treated as a such rather than as an array arguments.

Parameters
$method : callable
$limit : int
$arguments : mixed
Return values
array<string|int, mixed>

evaluateArrayArgumentsSubsetFrom()

Handles array argument processing when the function accepts multiple arguments, but only the last few (from start) can be an array arguments.

protected static evaluateArrayArgumentsSubsetFrom(callable $method, int $start, mixed ...$arguments) : array<string|int, mixed>

Example use for: Z.TEST() or INDEX(), where the first argument 1 is a matrix that needs to be treated as a dataset rather than as an array argument.

Parameters
$method : callable
$start : int
$arguments : mixed
Return values
array<string|int, mixed>

evaluateSingleArgumentArray()

Handles array argument processing when the function accepts a single argument that can be an array argument.

protected static evaluateSingleArgumentArray(callable $method, array<string|int, mixed> $values) : array<string|int, mixed>

Example use for: DAYOFMONTH() or FACT().

Parameters
$method : callable
$values : array<string|int, mixed>
Return values
array<string|int, mixed>

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

        
On this page

Search results