Logo

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.

nxks
500.61
1000.4242640687119291
5000.1897366596101031
10000.1341640786499871
50000.061
100000.04242640687119291
500000.01897366596101031
10000000.004242640687119280.999999999999956
100000000.001341640786499870.999999999999956
1000000000.0004242640687119290.999999999999956
10000000000.0001341640786499871