Class KolmogorovSmirnovTest.TwoResult
- All Implemented Interfaces:
SignificanceResult
- Enclosing class:
KolmogorovSmirnovTest
This class is immutable.
- Since:
- 1.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
Flag to indicate there were significant ties.private final double
Upper bound of the D statistic from all possible paths through regions with ties.private final double
The p-value of the upper D value. -
Constructor Summary
ConstructorsConstructorDescriptionTwoResult
(double statistic, int sign, double p, boolean significantTies, double upperD, double upperP) Create an instance. -
Method Summary
Modifier and TypeMethodDescriptiondouble
Returns the test statistic.double
Return the upper bound of the D statistic from all possible paths through regions with ties.double
Return the p-value of the upper bound of the D statistic.boolean
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 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 Details
-
significantTies
private final boolean significantTiesFlag to indicate there were significant ties. Note that in extreme cases there may be significant ties despiteupperD == D
due 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 upperDUpper bound of the D statistic from all possible paths through regions with ties. -
upperP
private final double upperPThe p-value of the upper D value.
-
-
Constructor Details
-
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 Details
-
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
- Overrides:
getStatistic
in classBaseSignificanceResult
- 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
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:
-
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:
-