Class KruskalWallisTest
java.lang.Object
org.moeaframework.util.statistics.OrdinalStatisticalTest
org.moeaframework.util.statistics.KruskalWallisTest
- All Implemented Interfaces:
StatisticalTest
The Kruskal-Wallis One-Way Analysis of Variance by Ranks is a non-parametric statistical test determining if
(at least) two out of K >= 2 populations have differing medians.
- Null Hypothesis: All populations have equal medians.
- Alternative Hypothesis: Not all populations have equal medians.
Assumptions:
- Samples are randomly selected from their corresponding populations
- Samples are independent
- The dependent variable (value being sampled) is continuous
- The underlying distributions of the populations are identical in shape
References:
- Kruskal, W.H. and Wallis W.A. "Use of Ranks in One-Criterion Variance Analysis." Journal of the American Statistical Association, 47(260):583-621, 1952.
- Sheskin, D.J. "Handbook of Parametric and Nonparametric Statistical Procedures, Third Edition." Chapman & Hall/CRC. 2004.
-
Field Summary
Fields inherited from class org.moeaframework.util.statistics.OrdinalStatisticalTest
comparator, data, numberOfGroups
-
Constructor Summary
ConstructorDescriptionKruskalWallisTest
(int numberOfGroups) Constructs a Kruskal-Wallis test with the specified number of groups. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(double value, int group) Adds a new observation with the specified value and group.void
addAll
(double[] values, int group) Adds several new observations to the specified group.org.apache.commons.math3.stat.descriptive.DescriptiveStatistics
getStatistics
(int group) Returns the descriptive statistics for the given group.boolean
test
(double alpha) Returnstrue
if the null hypothesis is rejected;false
otherwise.Methods inherited from class org.moeaframework.util.statistics.OrdinalStatisticalTest
getComparator, getNumberOfGroups, size, update
-
Constructor Details
-
KruskalWallisTest
public KruskalWallisTest(int numberOfGroups) Constructs a Kruskal-Wallis test with the specified number of groups.- Parameters:
numberOfGroups
- the number of groups being tested
-
-
Method Details
-
add
public void add(double value, int group) Description copied from class:OrdinalStatisticalTest
Adds a new observation with the specified value and group.- Overrides:
add
in classOrdinalStatisticalTest
- Parameters:
value
- the value of the new observationgroup
- the group to which the new observation belongs
-
addAll
public void addAll(double[] values, int group) Description copied from class:OrdinalStatisticalTest
Adds several new observations to the specified group.- Overrides:
addAll
in classOrdinalStatisticalTest
- Parameters:
values
- the values of the new observationsgroup
- the group to which the new observations belong
-
getStatistics
public org.apache.commons.math3.stat.descriptive.DescriptiveStatistics getStatistics(int group) Description copied from class:OrdinalStatisticalTest
Returns the descriptive statistics for the given group.- Overrides:
getStatistics
in classOrdinalStatisticalTest
- Parameters:
group
- the group- Returns:
- the descriptive statistics
-
test
public boolean test(double alpha) Description copied from interface:StatisticalTest
Returnstrue
if the null hypothesis is rejected;false
otherwise. The meaning of the null hypothesis and alternative hypothesis depends on the specific test.The prespecified level of confidence, alpha, can be used for either one-tailed or two-tailed (directional or non-directional) distributions, depending on the specific test. Some tests may only support specific values for alpha.
- Parameters:
alpha
- the prespecified level of confidence- Returns:
true
if the null hypothesis is rejected;false
otherwise
-