Logo

SQL Server KSccdf Function

Updated 2023-11-03 16:00:00.023000

Description

Use the scalar function KSccdf to compute the complementary cumulative probability P[D n >= x] of the Kolmogorov-Smirnov distribution with sample size n at x.

Syntax

SELECT [westclintech].[wct].[KSccdf](
  <@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 KSccdf = 1.

If @x < 0 then KSccdf = 1.

Examples

SELECT n,
       sqrt(18.0 / n) as x,
       wct.KSCCDF(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.

nxks
500.69.6340704561422E-18
1000.4242640687119297.60653219848608E-17
5000.1897366596101033.09340954271647E-16
10000.1341640786499873.69599264243387E-16
50000.064.33712332368773E-16
100000.04242640687119294.44862619998983E-16
500000.01897366596101034.56828378005821E-16
10000000.004242640687119284.62531376662394E-16
100000000.001341640786499874.63483518913332E-16
1000000000.0004242640687119294.63772741835367E-16
10000000000.0001341640786499874.63863011932784E-16