naginterfaces.library.nonpar.test_ks_1sample_user¶
- naginterfaces.library.nonpar.test_ks_1sample_user(x, cdf, ntype, data=None)[source]¶
test_ks_1sample_user
performs the one sample Kolmogorov–Smirnov distribution test, using a user-specified distribution.For full information please refer to the NAG Library document for g08cc
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/g08/g08ccf.html
- Parameters
- xfloat, array-like, shape
The sample observations, .
- cdfcallable retval = cdf(x, data=None)
must return the value of the theoretical (null) cumulative distribution function for a given value of its argument.
- Parameters
- xfloat
The argument for which must be evaluated.
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- retvalfloat
The value of the theoretical (null) cumulative distribution function evaluated at .
- ntypeint
The statistic to be calculated, i.e., the choice of alternative hypothesis.
Computes , to test against .
Computes , to test against .
Computes , to test against .
- dataarbitrary, optional
User-communication data for callback functions.
- Returns
- dfloat
The Kolmogorov–Smirnov test statistic (, or according to the value of ).
- zfloat
A standardized value, , of the test statistic, , without the continuity correction applied.
- pfloat
The probability, , associated with the observed value of , where may , or depending on the value of (see Notes).
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: , or .
- (errno )
On entry, at , .
Constraint: .
- (errno )
On entry, at , and at ,
Constraint: when , .
- Notes
No equivalent traditional C interface for this routine exists in the NAG Library.
The data consists of a single sample of observations, denoted by . Let and represent the sample cumulative distribution function and the theoretical (null) cumulative distribution function respectively at the point , where is the th smallest sample observation.
The Kolmogorov–Smirnov test provides a test of the null hypothesis : the data are a random sample of observations from a theoretical distribution specified by you (in ) against one of the following alternative hypotheses.
: the data cannot be considered to be a random sample from the specified null distribution.
: the data arise from a distribution which dominates the specified null distribution. In practical terms, this would be demonstrated if the values of the sample cumulative distribution function tended to exceed the corresponding values of the theoretical cumulative distribution function .
: the data arise from a distribution which is dominated by the specified null distribution. In practical terms, this would be demonstrated if the values of the theoretical cumulative distribution function tended to exceed the corresponding values of the sample cumulative distribution function .
One of the following test statistics is computed depending on the particular alternative hypothesis specified (see the description of the argument in Parameters).
For the alternative hypothesis :
– the largest absolute deviation between the sample cumulative distribution function and the theoretical cumulative distribution function. Formally .
For the alternative hypothesis :
– the largest positive deviation between the sample cumulative distribution function and the theoretical cumulative distribution function. Formally .
For the alternative hypothesis :
– the largest positive deviation between the theoretical cumulative distribution function and the sample cumulative distribution function. Formally . This is only true for continuous distributions. See Further Comments for comments on discrete distributions.
The standardized statistic, , is also computed, where may be or depending on the choice of the alternative hypothesis. This is the standardized value of with no continuity correction applied and the distribution of converges asymptotically to a limiting distribution, first derived by Kolmogorov (1933), and then tabulated by Smirnov (1948). The asymptotic distributions for the one-sided statistics were obtained by Smirnov (1933).
The probability, under the null hypothesis, of obtaining a value of the test statistic as extreme as that observed, is computed. If , an exact method given by Conover (1980) is used. Note that the method used is only exact for continuous theoretical distributions and does not include Conover’s modification for discrete distributions. This method computes the one-sided probabilities. The two-sided probabilities are estimated by doubling the one-sided probability. This is a good estimate for small , that is , but it becomes very poor for larger . If then is computed using the Kolmogorov–Smirnov limiting distributions; see Feller (1948), Kendall and Stuart (1973), Kolmogorov (1933), Smirnov (1933) and 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
Kolmogorov, A N, 1933, Sulla determinazione empirica di una legge di distribuzione, Giornale dell’ Istituto Italiano degli Attuari (4), 83–91
Siegel, S, 1956, Non-parametric Statistics for the Behavioral Sciences, McGraw–Hill
Smirnov, N, 1933, Estimate of deviation between empirical distribution functions in two independent samples, Bull. Moscow Univ. (2(2)), 3–16
Smirnov, N, 1948, Table for estimating the goodness of fit of empirical distributions, Ann. Math. Statist. (19), 279–281