Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_stat_prob_kolmogorov1 (g01ey)

## Purpose

nag_stat_prob_kolmogorov1 (g01ey) returns the upper tail probability associated with the one sample Kolmogorov–Smirnov distribution.

## Syntax

[result, ifail] = g01ey(n, d)
[result, ifail] = nag_stat_prob_kolmogorov1(n, d)

## Description

Let Sn(x)${S}_{n}\left(x\right)$ be the sample cumulative distribution function and F0(x)${F}_{0}\left(x\right)$ the hypothesised theoretical distribution function.
nag_stat_prob_kolmogorov1 (g01ey) returns the upper tail probability, p$p$, associated with the one-sided Kolmogorov–Smirnov test statistic Dn + ${D}_{n}^{+}$ or Dn${D}_{n}^{-}$, where these one-sided statistics are defined as follows;
 Dn + = supx[Sn(x) − F0(x)], Dn − = supx[F0(x) − Sn(x)[.
$Dn+ = supx[Sn(x)-F0(x)], Dn- = supx[F0(x)-Sn(x)[.$
If n100$n\le 100$ an exact method is used; for the details see Conover (1980). Otherwise a large sample approximation derived by Smirnov is used; see Feller (1948), Kendall and Stuart (1973) or Smirnov (1948).

## References

Conover W J (1980) Practical Nonparametric Statistics Wiley
Feller W (1948) On the Kolmogorov–Smirnov limit theorems for empirical distributions Ann. Math. Statist. 19 179–181
Kendall M G and Stuart A (1973) The Advanced Theory of Statistics (Volume 2) (3rd Edition) Griffin
Siegel S (1956) Non-parametric Statistics for the Behavioral Sciences McGraw–Hill
Smirnov N (1948) Table for estimating the goodness of fit of empirical distributions Ann. Math. Statist. 19 279–281

## Parameters

### Compulsory Input Parameters

1:     n – int64int32nag_int scalar
n$n$, the number of observations in the sample.
Constraint: n1${\mathbf{n}}\ge 1$.
2:     d – double scalar
Contains the test statistic, Dn + ${D}_{n}^{+}$ or Dn${D}_{n}^{-}$.
Constraint: 0.0d1.0$0.0\le {\mathbf{d}}\le 1.0$.

None.

None.

### Output Parameters

1:     result – double scalar
The result of the function.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, n < 1${\mathbf{n}}<1$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, d < 0.0${\mathbf{d}}<0.0$, or d > 1.0${\mathbf{d}}>1.0$.

## Accuracy

The large sample distribution used as an approximation to the exact distribution should have a relative error of less than 2.5$2.5$% for most cases.

The upper tail probability for the two-sided statistic, Dn = max (Dn + ,Dn)${D}_{n}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({D}_{n}^{+},{D}_{n}^{-}\right)$, can be approximated by twice the probability returned via nag_stat_prob_kolmogorov1 (g01ey), that is 2p$2p$. (Note that if the probability from nag_stat_prob_kolmogorov1 (g01ey) is greater than 0.5$0.5$ then the two-sided probability should be truncated to 1.0$1.0$). This approximation to the tail probability for Dn${D}_{n}$ is good for small probabilities, (e.g., p0.10$p\le 0.10$) but becomes very poor for larger probabilities.
The time taken by the function increases with n$n$, until n > 100$n>100$. At this point the approximation is used and the time decreases significantly. The time then increases again modestly with n$n$.

## Example

```function nag_stat_prob_kolmogorov1_example
n = int64(10);
d = 0.323;
[result, ifail] = nag_stat_prob_kolmogorov1(n, d)
```
```

result =

0.0994

ifail =

0

```
```function g01ey_example
n = int64(10);
d = 0.323;
[result, ifail] = g01ey(n, d)
```
```

result =

0.0994

ifail =

0

```