Package elki.math.statistics.tests
Class KolmogorovSmirnovTest
- java.lang.Object
-
- elki.math.statistics.tests.KolmogorovSmirnovTest
-
- All Implemented Interfaces:
GoodnessOfFitTest
public class KolmogorovSmirnovTest extends java.lang.Object implements GoodnessOfFitTest
Kolmogorov-Smirnov test.Class that tests two given real-valued data samples on whether they might have originated from the same underlying distribution using the Kolmogorov-Smirnov test statistic that compares the two empirical cumulative distribution functions. The KS statistic is defined as the maximum absolute difference of the empirical CDFs.
- Since:
- 0.5.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
KolmogorovSmirnovTest.Par
Parameterizer, to use the static instance.
-
Field Summary
Fields Modifier and Type Field Description static KolmogorovSmirnovTest
STATIC
Static instance
-
Constructor Summary
Constructors Constructor Description KolmogorovSmirnovTest()
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static double
calculateTestStatistic(double[] sample1, double[] sample2)
Calculates the maximum distance between the two empirical CDFs of two data samples.double
deviation(double[] fullSample, double[] conditionalSample)
Measure the deviation of a full sample from a conditional sample.static double
simpleTest(double[] test)
Simplest version of the test: test if a sorted array is approximately uniform distributed on [0:1].static double
simpleTest(double[] test, double min, double max)
Simplest version of the test: test if a sorted array is approximately uniform distributed on the given interval.
-
-
-
Field Detail
-
STATIC
public static final KolmogorovSmirnovTest STATIC
Static instance
-
-
Method Detail
-
deviation
public double deviation(double[] fullSample, double[] conditionalSample)
Description copied from interface:GoodnessOfFitTest
Measure the deviation of a full sample from a conditional sample.Sample arrays may be modified, e.g., sorted, by the test.
- Specified by:
deviation
in interfaceGoodnessOfFitTest
- Parameters:
fullSample
- Full sampleconditionalSample
- Conditional sample- Returns:
- Deviation
-
calculateTestStatistic
public static double calculateTestStatistic(double[] sample1, double[] sample2)
Calculates the maximum distance between the two empirical CDFs of two data samples. The sample positions and CDFs must be synchronized!- Parameters:
sample1
- first data sample positionssample2
- second data sample positions- Returns:
- the largest difference between both functions
-
simpleTest
public static double simpleTest(double[] test)
Simplest version of the test: test if a sorted array is approximately uniform distributed on [0:1].- Parameters:
test
- Presorted (!) array- Returns:
- Maximum deviation from uniform.
-
simpleTest
public static double simpleTest(double[] test, double min, double max)
Simplest version of the test: test if a sorted array is approximately uniform distributed on the given interval.- Parameters:
test
- Presorted (!) arraymin
- Minimum of uniform distributionmax
- Maximum of uniform distribution- Returns:
- Maximum deviation from uniform.
-
-