Class OneWayAnovaImpl
java.lang.Object
org.apache.commons.math.stat.inference.OneWayAnovaImpl
- All Implemented Interfaces:
OneWayAnova
Implements one-way ANOVA statistics defined in the
OneWayAnovaImpl
interface.
Uses the
commons-math F Distribution implementation to estimate exact p-values.
This implementation is based on a description at http://faculty.vassar.edu/lowry/ch13pt1.html
Abbreviations: bg = between groups,
wg = within groups,
ss = sum squared deviations
- Since:
- 1.2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleanovaFValue(Collection<double[]> categoryData) Computes the ANOVA F-value for a collection ofdouble[]arrays.doubleanovaPValue(Collection<double[]> categoryData) Computes the ANOVA P-value for a collection ofdouble[]arrays.booleananovaTest(Collection<double[]> categoryData, double alpha) Performs an ANOVA test, evaluating the null hypothesis that there is no difference among the means of the data categories.
-
Constructor Details
-
OneWayAnovaImpl
public OneWayAnovaImpl()Default constructor.
-
-
Method Details
-
anovaFValue
public double anovaFValue(Collection<double[]> categoryData) throws IllegalArgumentException, MathException Computes the ANOVA F-value for a collection ofdouble[]arrays.Preconditions:
- The categoryData
Collectionmust containdouble[]arrays. - There must be at least two
double[]arrays in thecategoryDatacollection and each of these arrays must contain at least two values.
This implementation computes the F statistic using the definitional formula
F = msbg/mswg
wheremsbg = between group mean square mswg = within group mean square
are as defined here- Specified by:
anovaFValuein interfaceOneWayAnova- Parameters:
categoryData-Collectionofdouble[]arrays each containing data for one category- Returns:
- Fvalue
- Throws:
IllegalArgumentException- if the preconditions are not metMathException- if the statistic can not be computed do to a convergence or other numerical error.
- The categoryData
-
anovaPValue
public double anovaPValue(Collection<double[]> categoryData) throws IllegalArgumentException, MathException Computes the ANOVA P-value for a collection ofdouble[]arrays.Preconditions:
- The categoryData
Collectionmust containdouble[]arrays. - There must be at least two
double[]arrays in thecategoryDatacollection and each of these arrays must contain at least two values.
This implementation uses the
commons-math F Distribution implementationto estimate the exact p-value, using the formulap = 1 - cumulativeProbability(F)
whereFis the F value andcumulativeProbabilityis the commons-math implementation of the F distribution.- Specified by:
anovaPValuein interfaceOneWayAnova- Parameters:
categoryData-Collectionofdouble[]arrays each containing data for one category- Returns:
- Pvalue
- Throws:
IllegalArgumentException- if the preconditions are not metMathException- if the statistic can not be computed do to a convergence or other numerical error.
- The categoryData
-
anovaTest
public boolean anovaTest(Collection<double[]> categoryData, double alpha) throws IllegalArgumentException, MathException Performs an ANOVA test, evaluating the null hypothesis that there is no difference among the means of the data categories.Preconditions:
- The categoryData
Collectionmust containdouble[]arrays. - There must be at least two
double[]arrays in thecategoryDatacollection and each of these arrays must contain at least two values. - alpha must be strictly greater than 0 and less than or equal to 0.5.
This implementation uses the
commons-math F Distribution implementationto estimate the exact p-value, using the formulap = 1 - cumulativeProbability(F)
whereFis the F value andcumulativeProbabilityis the commons-math implementation of the F distribution.True is returned iff the estimated p-value is less than alpha.
- Specified by:
anovaTestin interfaceOneWayAnova- Parameters:
categoryData-Collectionofdouble[]arrays each containing data for one categoryalpha- significance level of the test- Returns:
- true if the null hypothesis can be rejected with confidence 1 - alpha
- Throws:
IllegalArgumentException- if the preconditions are not metMathException- if the statistic can not be computed do to a convergence or other numerical error.
- The categoryData
-