NCTCDF
Updated 2024-03-12 20:29:51.310000
Syntax
SELECT [westclintech].[wct].[NCTCDF] (
<@X, float,>
,<@DF, float,>
,<@Delta, float,>)1
Description
Use the scalar function NCTCDF to calculate the lower cumulative distribution function of the non-central T distribution.
The formula for the lower cumulative distribution function is:
F_{\nu,\mu}(x)=\begin{cases} \tilde{F}_{\nu,\mu}(x), & \mbox{if } x\ge 0; \\ 1-\tilde{F}_{\nu, -\mu}(x), &\mbox{if } x < 0, \end{cases}
Where
\tilde{F}_{\nu,\mu}(x)=\Phi(-\mu)+\frac{1}{2}\sum_{j=0}^\infty\left[{p_j}{I_y}\left(j+\frac{1}{2},\frac{\nu}{2}\right)+{q_j}{I_y}\left(j+1,\frac{\nu}{2}\right)\right],
I_y\,\!(a,b)\text{ is the regularized incomplete beta function,}
y=\frac{x^2}{x^2+\nu},
p_j=\frac{1}{j!}\exp\left\{-\frac{\mu^2}{2}\right\}\left(\frac{\mu^2}{2}\right)^j,
q_j=\frac{\mu}{\sqrt{2}\Gamma(j+3/2)}\exp\left\{-\frac{\mu^2}{2}\right\}\left(\frac{\mu^2}{2}\right)^j,
and Φ is the cumulative distribution function of the standard normal distribution.
Arguments
@Delta
is the non-centrality parameter. @Delta is an expression of type float or of a type that implicitly converts to float.
@X
is the variable to be evaluated. @X is an expression of type float or of a type that implicitly converts to float.
@DF
degrees of freedom. @DF is an expression of type float or of a type that implicitly converts to float.
Return Type
float
Remarks
@X must be greater than zero (@X > 0).
@DF must be greater than zero (@DF > 0).
@Lambda must be greater than or equal to zero (@Lambda > 0).
Examples
Calculate the lower cumulative distribution function:
SELECT wct.NCTCDF(1,3,3);
This produces the following result.
----------------------
0.0270004801469904
You can use the SeriesFloat 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.NCFCDF(SeriesValue, 1, 1, 1) as [f(x,1,1,1)],
wct.NCFCDF(SeriesValue, 1, 2, 1) as [f(x,1,2,1)],
wct.NCFCDF(SeriesValue, 2, 1, 2) as [f(x,2,1,2)],
wct.NCFCDF(SeriesValue, 2, 2, 1) as [f(x,2,2,1)],
wct.NCFCDF(SeriesValue, 3, 1, 2) as [f(x,3,1,2)]
FROM wct.SeriesFloat(.1, 10, .1, NULL, NULL);
This is an EXCEL-generated graph of the results.
Calculate the upper cumulative distribution:
SELECT 1 - wct.NCTCDF(1, 3, 3);
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"0.97299951985301"}]}