POISSON
Updated 2024-03-13 13:20:23.237000
Syntax
SELECT [westclintech].[wct].[POISSON] (
<@X, float,>
,<@Mean, float,>
,<@Cumulative, bit,>)
Description
Use the scalar function POISSON to calculate the Poisson distribution. The formula for the probability mass function (pmf) is:
f(k; \lambda) = \Pr(X{=}k)= \frac{\lambda^k e^{-\lambda}}{k!}
where k is the number of occurrences and λ is the mean.
The formula for the cumulative distribution function (cdf) is:
F(k; \lambda) =Q(\lfloor{k+1}\rfloor,\lambda)
Where Q(a,x) is the regularized gamma function
Arguments
@Mean
is the arithmetic mean of the distribution. @Mean is an expression of type float or of a type that can be implicitly converted to float.
@X
is the number of events. @X is an expression of type float or of a type that can be implicitly converted to float.
@Cumulative
is a logical value that determines if the probability density function (False, 0) or the cumulative distribution function (True, 1) is being calculated.
Return Type
float
Remarks
@X is truncated to zero decimal places.
If @X < 0, POISSON returns an error.
If @Mean < 0, POISSON returns an error.
Examples
select wct.POISSON(2, 5, 'False');
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"0.0842243374885683"}]}
select wct.POISSON(2, 5, 'True');
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"0.124652019483081"}]}