Class KSTest
The two-sample KS test is one of the most useful and general non-parametric methods for comparing two samples, as it is sensitive to differences in both location and shape of the empirical cumulative distribution functions of the two samples.
The Kolmogorov-Smirnov test can be modified to serve goodness of fit test. In the special case of testing for normality of the distribution, samples are standardized and compared with a standard normal distribution. This is equivalent to setting the mean and variance of the reference distribution equal to the sample estimates, and it is known that using the sample to modify the null hypothesis reduces the power of a test. Correcting for this bias leads to the Lilliefors test. However, even Lilliefors' modification is less powerful than the Shapiro-Wilk test or Anderson-Darling test for testing normality.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic KSTest
test
(double[] x, double[] y) The two-sample KS test for the null hypothesis that the data sets are drawn from the same distribution.static KSTest
test
(double[] x, Distribution dist) The one-sample KS test for the null hypothesis that the data set x is drawn from the given distribution.toString()
-
Field Details
-
method
The type of test. -
d
public final double dKolmogorov-Smirnov statistic. -
pvalue
public final double pvalueP-value.
-
-
Constructor Details
-
KSTest
Constructor.- Parameters:
method
- the type of test.d
- the Kolmogorov-Smirnov statistic.pvalue
- the p-value.
-
-
Method Details
-
toString
-
test
The one-sample KS test for the null hypothesis that the data set x is drawn from the given distribution. Small values of p-value show that the cumulative distribution function of x is significantly different from the given distribution. The array x is modified by being sorted into ascending order.- Parameters:
x
- the sample values.dist
- the distribution.- Returns:
- the test results.
-
test
The two-sample KS test for the null hypothesis that the data sets are drawn from the same distribution. Small values of p-value show that the cumulative distribution function of x is significantly different from that of y. The arrays x and y are modified by being sorted into ascending order.- Parameters:
x
- the sample values.y
- the sample values.- Returns:
- the test results.
-