POISSON_DIST
Updated 2023-11-05 12:09:03.517000
Syntax
SELECT [westclintech].[wct].[POISSON_DIST](
<@X, float,>
,<@Mean, float,>
,<@Cumulative, bit,>)
Description
Use the scalar function POISSON_DIST to calculate the probability mass function or the lower cumulative probability of a Poisson distribution for a given number of events occurring in a fixed interval given the rate.
Arguments
@Mean
the rate at which events occur during the interval. @Mean must be of a type float or of a type that intrinsically converts to float.
@X
the number of events. @X must be of a type float or of type that intrinsically converts to float.
@Cumulative
A bit value indicating whether the probability density function ( 'False') or the cumulative distribution function ( 'True') should be returned.
Return Type
float
Remarks
@X is truncated and the integer value is used.
0 < @X.
0 < @Mean.
Examples
A phone support center averages 43 calls per hour. In this example we calculate the likelihood that it will receive exactly 47 calls in an hour.
SELECT wct.POISSON( 47, --@X
43, --@Mean
'False' --@Cumulative
) as pmf;
This produces the following result.
{"columns":[{"field":"pmf","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"pmf":"0.0484939030267833"}]}
If we wanted to know the likelihood that it would receive up to 47 calls in an hour, we would use the left-tailed cumulative probability.
SELECT wct.POISSON( 47, --@X
43, --@Mean
'True' --@Cumulative
) as cdf;
This produces the following result.
{"columns":[{"field":"cdf","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"cdf":"0.757980664887575"}]}
Since the Poisson distribution is a discrete distribution the cumulative distribution function, in this case, is the sum of the probabilities for each value from 0 to 47. We can use the XLeratorDB SeriesInt table-valued function to generate all the integer values from 0 to 47.
SELECT SUM(wct.POISSON_DIST(SeriesValue, 43, 'False')) as cdf
FROM wct.SeriesInt(0, 47, NULL, NULL, NULL);
This produces the following result.
{"columns":[{"field":"cdf","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"cdf":"0.75798066488758"}]}
The Poisson distribution is a special case of the gamma distribution.
SELECT wct.POISSON_DIST(x, lambda, 'True') as POISSON_DIST,
wct.GAMMAQ(x + 1, lambda) as GAMMAQ
FROM
(
VALUES
(5, 3)
) n (x, lambda);
This produces the following result.
{"columns":[{"field":"POISSON_DIST","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"GAMMAQ","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"POISSON_DIST":"0.916082057968696","GAMMAQ":"0.916082057968696"}]}