Class KolmogorovSmirnovTest.TwoResult
- java.lang.Object
-
- org.apache.commons.statistics.inference.BaseSignificanceResult
-
- 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
-
-
Field Summary
Fields Modifier and Type Field Description private booleansignificantTiesFlag to indicate there were significant ties.private doubleupperDUpper bound of the D statistic from all possible paths through regions with ties.private doubleupperPThe p-value of the upper D value.
-
Constructor Summary
Constructors Constructor Description TwoResult(double statistic, int sign, double p, boolean significantTies, double upperD, double upperP)Create an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetStatistic()Returns the test statistic.doublegetUpperD()Return the upper bound of the D statistic from all possible paths through regions with ties.doublegetUpperPValue()Return the p-value of the upper bound of the D statistic.booleanhasSignificantTies()Returnstrueif 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 org.apache.commons.statistics.inference.BaseSignificanceResult
getPValue
-
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
-
-
-
-
Field Detail
-
significantTies
private final boolean significantTies
Flag to indicate there were significant ties. Note that in extreme cases there may be significant ties despiteupperD == Ddue to rounding when converting the integral statistic to a double. For this reason the presence of ties is stored as a flag.
-
upperD
private final double upperD
Upper bound of the D statistic from all possible paths through regions with ties.
-
upperP
private final double upperP
The p-value of the upper D value.
-
-
Constructor Detail
-
TwoResult
TwoResult(double statistic, int sign, double p, boolean significantTies, double upperD, double upperP)Create an instance.- Parameters:
statistic- Test statistic.sign- Sign of the statistic.p- Result p-value.significantTies- Flag to indicate there were significant ties.upperD- Upper bound of the D statistic from all possible paths through regions with ties.upperP- The p-value of the upper D value.
-
-
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-valueof 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:
getStatisticin interfaceSignificanceResult- Overrides:
getStatisticin classBaseSignificanceResult- Returns:
- the statistic
-
hasSignificantTies
public boolean hasSignificantTies()
Returnstrueif 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
xbefore 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
truewhenD == upperDdue to rounding when converting the computed D statistic to a double. This will only occur for large sample sizesnandmwhere 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
NaNif thep-valuewas 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()
-
-