Class KolmogorovSmirnovDistribution
- java.lang.Object
-
- org.apache.commons.math3.distribution.KolmogorovSmirnovDistribution
-
- All Implemented Interfaces:
java.io.Serializable
public class KolmogorovSmirnovDistribution extends java.lang.Object implements java.io.Serializable
Deprecated.to be removed in version 4.0 - useKolmogorovSmirnovTest
Implementation of the Kolmogorov-Smirnov distribution.Treats the distribution of the two-sided
P(D_n < d)
whereD_n = sup_x |G(x) - G_n (x)|
for the theoretical cdfG
and the empirical cdfG_n
.This implementation is based on [1] with certain quick decisions for extreme values given in [2].
In short, when wanting to evaluate
P(D_n < d)
, the method in [1] is to writed = (k - h) / n
for positive integerk
and0 <= h < 1
. ThenP(D_n < d) = (n! / n^n) * t_kk
, wheret_kk
is the(k, k)
'th entry in the special matrixH^n
, i.e.H
to then
'th power.References:
- [1] Evaluating Kolmogorov's Distribution by George Marsaglia, Wai Wan Tsang, and Jingbo Wang
- [2] Computing the Two-Sided Kolmogorov-Smirnov Distribution by Richard Simard and Pierre L'Ecuyer
-
-
Field Summary
Fields Modifier and Type Field Description private int
n
Deprecated.Number of observations.private static long
serialVersionUID
Deprecated.Serializable version identifier.
-
Constructor Summary
Constructors Constructor Description KolmogorovSmirnovDistribution(int n)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description double
cdf(double d)
Deprecated.CalculatesP(D_n < d)
using method described in [1] with quick decisions for extreme values given in [2] (see above).double
cdf(double d, boolean exact)
Deprecated.CalculatesP(D_n < d)
using method described in [1] with quick decisions for extreme values given in [2] (see above).double
cdfExact(double d)
Deprecated.CalculatesP(D_n < d)
using method described in [1] with quick decisions for extreme values given in [2] (see above).private FieldMatrix<BigFraction>
createH(double d)
Deprecated.CreatesH
of sizem x m
as described in [1] (see above).private double
exactK(double d)
Deprecated.Calculates the exact value ofP(D_n < d)
using method described in [1] andBigFraction
(see above).private double
roundedK(double d)
Deprecated.CalculatesP(D_n < d)
using method described in [1] and doubles (see above).
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Deprecated.Serializable version identifier.- See Also:
- Constant Field Values
-
n
private int n
Deprecated.Number of observations.
-
-
Constructor Detail
-
KolmogorovSmirnovDistribution
public KolmogorovSmirnovDistribution(int n) throws NotStrictlyPositiveException
Deprecated.- Parameters:
n
- Number of observations- Throws:
NotStrictlyPositiveException
- ifn <= 0
-
-
Method Detail
-
cdf
public double cdf(double d) throws MathArithmeticException
Deprecated.CalculatesP(D_n < d)
using method described in [1] with quick decisions for extreme values given in [2] (see above). The result is not exact as withcdfExact(double)
because calculations are based ondouble
rather thanBigFraction
.- Parameters:
d
- statistic- Returns:
- the two-sided probability of
P(D_n < d)
- Throws:
MathArithmeticException
- if algorithm fails to converth
to aBigFraction
in expressingd
as(k - h) / m
for integerk, m
and0 <= h < 1
.
-
cdfExact
public double cdfExact(double d) throws MathArithmeticException
Deprecated.CalculatesP(D_n < d)
using method described in [1] with quick decisions for extreme values given in [2] (see above). The result is exact in the sense that BigFraction/BigReal is used everywhere at the expense of very slow execution time. Almost never choose this in real applications unless you are very sure; this is almost solely for verification purposes. Normally, you would choosecdf(double)
- Parameters:
d
- statistic- Returns:
- the two-sided probability of
P(D_n < d)
- Throws:
MathArithmeticException
- if algorithm fails to converth
to aBigFraction
in expressingd
as(k - h) / m
for integerk, m
and0 <= h < 1
.
-
cdf
public double cdf(double d, boolean exact) throws MathArithmeticException
Deprecated.CalculatesP(D_n < d)
using method described in [1] with quick decisions for extreme values given in [2] (see above).- Parameters:
d
- statisticexact
- whether the probability should be calculated exact usingBigFraction
everywhere at the expense of very slow execution time, or ifdouble
should be used convenient places to gain speed. Almost never choosetrue
in real applications unless you are very sure;true
is almost solely for verification purposes.- Returns:
- the two-sided probability of
P(D_n < d)
- Throws:
MathArithmeticException
- if algorithm fails to converth
to aBigFraction
in expressingd
as(k - h) / m
for integerk, m
and0 <= h < 1
.
-
exactK
private double exactK(double d) throws MathArithmeticException
Deprecated.Calculates the exact value ofP(D_n < d)
using method described in [1] andBigFraction
(see above).- Parameters:
d
- statistic- Returns:
- the two-sided probability of
P(D_n < d)
- Throws:
MathArithmeticException
- if algorithm fails to converth
to aBigFraction
in expressingd
as(k - h) / m
for integerk, m
and0 <= h < 1
.
-
roundedK
private double roundedK(double d) throws MathArithmeticException
Deprecated.CalculatesP(D_n < d)
using method described in [1] and doubles (see above).- Parameters:
d
- statistic- Returns:
- the two-sided probability of
P(D_n < d)
- Throws:
MathArithmeticException
- if algorithm fails to converth
to aBigFraction
in expressingd
as(k - h) / m
for integerk, m
and0 <= h < 1
.
-
createH
private FieldMatrix<BigFraction> createH(double d) throws NumberIsTooLargeException, FractionConversionException
Deprecated.CreatesH
of sizem x m
as described in [1] (see above).- Parameters:
d
- statistic- Returns:
- H matrix
- Throws:
NumberIsTooLargeException
- if fractional part is greater than 1FractionConversionException
- if algorithm fails to converth
to aBigFraction
in expressingd
as(k - h) / m
for integerk, m
and0 <= h < 1
.
-
-