Class KolmogorovSmirnovTest.TwoResult
- java.lang.Object
-
- org.apache.commons.statistics.inference.KolmogorovSmirnovTest.OneResult
-
- org.apache.commons.statistics.inference.KolmogorovSmirnovTest.TwoResult
-
- All Implemented Interfaces:
SignificanceResult
- Enclosing class:
- KolmogorovSmirnovTest
public static final class KolmogorovSmirnovTest.TwoResult extends KolmogorovSmirnovTest.OneResult
Result for the two-sample Kolmogorov-Smirnov test.This class is immutable.
- Since:
- 1.1
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getPValue()
Returns the test statistic p-value.double
getStatistic()
Returns the test statistic.double
getUpperD()
Return the upper bound of the D statistic from all possible paths through regions with ties.double
getUpperPValue()
Return the p-value of the upper bound of the D statistic.boolean
hasSignificantTies()
Returnstrue
if there were ties between samples that occurred in a region which could change the D statistic if the ties were resolved to a defined order.-
Methods inherited from class org.apache.commons.statistics.inference.KolmogorovSmirnovTest.OneResult
getSign
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.statistics.inference.SignificanceResult
reject
-
-
-
-
Method Detail
-
getStatistic
public double getStatistic()
Returns the test statistic.Ties
The presence of ties in the data creates a distribution for the D values generated by all possible orderings of the tied regions. This statistic is computed using the path with the minimum effect on the D statistic.
For a one-sided statistic \(D^+\) or \(D^-\), this is the lower bound of the D statistic.
For a two-sided statistic D, this may be below the lower bound of the distribution of all possible D values. This case occurs when the number of ties is very high and is identified by a
p-value
of 1.If the two-sided statistic is zero this only occurs in the presence of ties: either the two arrays are identical, are 'identical' data of a single value (sample sizes may be different), or have a sequence of ties of 'identical' data with a net zero effect on the D statistic, e.g.
[1,2,3] vs [1,2,3] [0,0,0,0] vs [0,0,0] [0,0,0,0,1,1,1,1] vs [0,0,0,1,1,1]
- Specified by:
getStatistic
in interfaceSignificanceResult
- Returns:
- the statistic
-
hasSignificantTies
public boolean hasSignificantTies()
Returnstrue
if there were ties between samples that occurred in a region which could change the D statistic if the ties were resolved to a defined order.Ties between the data can be interpreted as if the values were different but within machine epsilon. In this case the order within the tie region is not known. If the most extreme ordering of any tied regions (e.g. all tied values of
x
before all tied values ofy
) could create a larger D statistic this method will returntrue
.If there were no ties, or all possible orderings of tied regions create the same D statistic, this method returns
false
.Note it is possible that this method returns
true
whenD == upperD
due to rounding when converting the computed D statistic to a double. This will only occur for large sample sizesn
andm
where the productn*m >= 2^53
.- Returns:
- true if the D statistic could be changed by resolution of ties
- See Also:
getUpperD()
-
getUpperD
public double getUpperD()
Return the upper bound of the D statistic from all possible paths through regions with ties.This will return a value equal to or greater than
getStatistic()
.- Returns:
- the upper bound of D
- See Also:
hasSignificantTies()
-
getUpperPValue
public double getUpperPValue()
Return the p-value of the upper bound of the D statistic.If computed, this will return a value equal to or less than
getPValue
. It may be orders of magnitude smaller.Note: This p-value corresponds to the most extreme p-value from all possible orderings of tied regions. It is not recommended to use this to reject the null hypothesis. The upper bound of D and the corresponding p-value provide information that must be interpreted in the context of the sample data and used to inform a decision on the suitability of the test to the data.
This value is set to
NaN
if thep-value
was estimated. The estimated p-value will have been created using a distribution of possible D values given the underlying joint distribution of the sample data. Comparison of the p-value to the upper p-value is not applicable.- Returns:
- the p-value of the upper bound of D (or NaN)
- See Also:
getUpperD()
-
getPValue
public double getPValue()
Description copied from interface:SignificanceResult
Returns the test statistic p-value.The number returned is the smallest significance level at which one can reject the null hypothesis.
- Specified by:
getPValue
in interfaceSignificanceResult
- Returns:
- the p-value
-
-