GEOMETRICP
Updated 2024-03-08 16:17:19.437000
Syntax
SELECT [westclintech].[wct].[GEOMETRICP] (
<@X, float,>
,<@P, float,>)
Description
Use the scalar function GEOMETRICP to calculate the cumulative distribution function of the geometric distribution.
The formula for the cumulative distribution function is:
Pr(k;p)=1-(1-p)^{{\lfloor{k}\rfloor}+1}
Arguments
@P
is the probability of success. @P is an expression of type float or of a type that implicitly converts to float.
@X
is the number of failures. @X is an expression of type float or of a type that implicitly converts to float.
Return Type
float
Remarks
@X must be greater than or equal to zero (@X ≥ 0).
@P must be greater than zero and less than or equal to one (0 < @P ≤ 1).
For the probability mass function, use GEOMETRIC.
For the upper cumulative distribution use 1 – GEOMTRICP(@X-1, @P).
Examples
Calculate the cumulative distribution function:
SELECT wct.GEOMETRICP(3, 0.4);
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"0.8704"}]}
You can use the SeriesInt function from the XLeratorDB/math library to generate a dataset which can be pasted into EXCEL to generate a graph of the cumulative distribution function.
SELECT SeriesValue,
wct.GEOMETRICP(SeriesValue, 0.1) as [f(x,0.1)],
wct.GEOMETRICP(SeriesValue, 0.3) as [f(x,0.3)],
wct.GEOMETRICP(SeriesValue, 0.5) as [f(x,0.5)],
wct.GEOMETRICP(SeriesValue, 0.7) as [f(x,0.7)],
wct.GEOMETRICP(SeriesValue, 0.9) as [f(x,0.9)]
FROM wct.SeriesInt(0, 10, NULL, NULL, NULL);
This is an EXCEL-generated graph of the results.