Class OneWayAnova
Tests for differences between two or more categories of univariate data
(for example, the body mass index of accountants, lawyers, doctors and
computer programmers). When two categories are given, this is equivalent to
the TTest
.
This implementation computes the F statistic using the definitional formula:
\[ F = \frac{\text{between-group variability}}{\text{within-group variability}} \]
- Since:
- 1.1
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Result for the one-way ANOVA. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static boolean
allMatch
(double v, double[] a) Return true if all values in the array match the specified value.private static boolean
allMatch
(Collection<double[]> data) Return true if all values in the arrays match.private static OneWayAnova.Result
aov
(Collection<double[]> data, double[] statistic) Performs an ANOVA test for a collection of category data, evaluating the null hypothesis that there is no difference among the means of the data categories.private static double
pow2
(double x) Computex^2
.double
statistic
(Collection<double[]> data) Computes the F statistic for an ANOVA test for a collection of category data, evaluating the null hypothesis that there is no difference among the means of the data categories.test
(Collection<double[]> data) Performs an ANOVA test for a collection of category data, evaluating the null hypothesis that there is no difference among the means of the data categories.static OneWayAnova
Return an instance using the default options.
-
Field Details
-
DEFAULT
Default instance.
-
-
Constructor Details
-
OneWayAnova
private OneWayAnova()Private constructor.
-
-
Method Details
-
withDefaults
Return an instance using the default options.- Returns:
- default instance
-
statistic
Computes the F statistic for an ANOVA test for a collection of category data, evaluating the null hypothesis that there is no difference among the means of the data categories.Special cases:
- Parameters:
data
- Category summary data.- Returns:
- F statistic
- Throws:
IllegalArgumentException
- if the number of categories is less than two; a contained category does not have at least one value; or all categories have only one value (zero degrees of freedom within groups)
-
test
Performs an ANOVA test for a collection of category data, evaluating the null hypothesis that there is no difference among the means of the data categories.Special cases:
- Parameters:
data
- Category summary data.- Returns:
- test result
- Throws:
IllegalArgumentException
- if the number of categories is less than two; a contained category does not have at least one value; or all categories have only one value (zero degrees of freedom within groups)
-
aov
Performs an ANOVA test for a collection of category data, evaluating the null hypothesis that there is no difference among the means of the data categories.This is a utility method to allow computation of the F statistic without the p-value or partitioning of the variance. If the
statistic
is not null the method will record the F statistic in the array and return null.- Parameters:
data
- Category summary data.statistic
- Result for the F statistic (or null).- Returns:
- test result (or null)
- Throws:
IllegalArgumentException
- if the number of categories is less than two; a contained category does not have at least one value; or all categories have only one value (zero degrees of freedom within groups)
-
allMatch
private static boolean allMatch(double v, double[] a) Return true if all values in the array match the specified value.- Parameters:
v
- Value.a
- Array.- Returns:
- true if all match
-
allMatch
Return true if all values in the arrays match.Assumes that there are at least two arrays and that each array has the same value throughout. Thus only the first element in each array is checked.
- Parameters:
data
- Arrays.- Returns:
- true if all match
-
pow2
private static double pow2(double x) Computex^2
.- Parameters:
x
- Value.- Returns:
x^2
-