SQL Server KScdf Function
Updated 2023-11-03 16:02:28.940000
Description
Use the scalar function KSccdf to compute the cumulative probability P[D n >= x] of the Kolmogorov-Smirnov distribution with sample size n at x.
Syntax
SELECT [westclintech].[wct].[KScdf](
<@n, int,>
,<@k, float,>)
Arguments
@n
is the sample size. @n is an expression of type int or of a type that can be implicitly converted to int.
Return Type
float
Remarks
If @n < 0 then KScdf = 1.
If @x < 0 then KScdf = 1.
Examples
SELECT n,
sqrt(18.0 / n) as x,
wct.KSCDF(n, sqrt(18.0 / n)) as ks
FROM
(
VALUES
(50.0),
(100.0),
(500.0),
(1000.0),
(5000.0),
(10000.0),
(50000.0),
(10E5),
(10E6),
(10E7),
(10E8)
) p (n);
This produces the following result.
| n | x | ks |
|---|---|---|
| 50 | 0.6 | 1 |
| 100 | 0.424264068711929 | 1 |
| 500 | 0.189736659610103 | 1 |
| 1000 | 0.134164078649987 | 1 |
| 5000 | 0.06 | 1 |
| 10000 | 0.0424264068711929 | 1 |
| 50000 | 0.0189736659610103 | 1 |
| 1000000 | 0.00424264068711928 | 0.999999999999956 |
| 10000000 | 0.00134164078649987 | 0.999999999999956 |
| 100000000 | 0.000424264068711929 | 0.999999999999956 |
| 1000000000 | 0.000134164078649987 | 1 |