GAMMADIST
Updated 2024-03-08 15:02:39.010000
Syntax
SELECT [westclintech].[wct].[GAMMADIST] (
<@X, float,>
,<@Alpha, float,>
,<@BETA, float,>
,<@Cumulative, bit,>)
Description
Use the scalar function GAMMADIST to calculate the gamma distribution. The formula for the probability density function of the gamma distribution is:
f(x;\alpha,\beta)=\frac{x^{\alpha-1}e^{-\beta x}\beta^\alpha}{\Gamma(\alpha)}\quad\text{ for } x > 0\quad \alpha, \beta > 0
Where Γ(𝑎) is the gamma function.
And the cumulative distribution function is the lower regularized incomplete gamma function
F(x;\alpha,\beta)=\frac{\gamma(\alpha,\beta{x})}{\Gamma(a)}
where γ(α, βx) is the lower incomplete gamma function.
Arguments
@Cumulative
is a logical value that determines if the probability density function (False, 0) or the cumulative distribution function (True, 1) is being calculated.
@X
is the value at which you want to evaluate the distribution. @X is an expression of type float or of a type that can be implicitly converted to float.
@Alpha
is the alpha parameter to the distribution. @Alpha is an expression of type float or of a type that can be implicitly converted to float.
@BETA
is the beta parameter to the distribution. @BETA is an expression of type float or of a type that can be implicitly converted to float.
Return Type
float
Remarks
If @X < 0, GAMMADIST will return an error.
If @Alpha = 0 or @BETA = 0, GAMMADIST will return an error.
Examples
select wct.GAMMADIST(10.00001131, 9, 2, 'False');
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"0.032639130418294"}]}
select wct.GAMMADIST(10.00001131, 9, 2, 'True');
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"0.0680940037098249"}]}
select wct.GAMMAP(9, 10.00001131 / 2);
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"0.0680940037098249"}]}
See Also
GAMMAINV - inverse gamma function
GAMMAP - lower regularized gamma function
GAMMAQ - upper regularized gamma function
INVGAMMAP - Calculate the inverse of the incomplete gamma functionP(a,x).
CHIDIST - chi-square distribution
GAMMA - complete gamma function