public class OneWayAnovaImpl extends Object implements OneWayAnova
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
Modifier and Type | Class and Description |
---|---|
private static class |
OneWayAnovaImpl.AnovaStats
Convenience class to pass dfbg,dfwg,F values around within AnovaImpl.
|
Constructor and Description |
---|
OneWayAnovaImpl()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
double |
anovaFValue(Collection<double[]> categoryData)
Computes the ANOVA F-value for a collection of
double[]
arrays. |
double |
anovaPValue(Collection<double[]> categoryData)
Computes the ANOVA P-value for a collection of
double[]
arrays. |
private OneWayAnovaImpl.AnovaStats |
anovaStats(Collection<double[]> categoryData)
This method actually does the calculations (except P-value).
|
boolean |
anovaTest(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.
|
public double anovaFValue(Collection<double[]> categoryData) throws IllegalArgumentException, MathException
double[]
arrays.
Preconditions:
Collection
must contain
double[]
arrays.double[]
arrays in the
categoryData
collection and each of these arrays must
contain at least two values.This implementation computes the F statistic using the definitional formula
F = msbg/mswgwhere
msbg = between group mean square mswg = within group mean squareare as defined here
anovaFValue
in interface OneWayAnova
categoryData
- Collection
of double[]
arrays each containing data for one categoryIllegalArgumentException
- if the preconditions are not metMathException
- if the statistic can not be computed do to a
convergence or other numerical error.public double anovaPValue(Collection<double[]> categoryData) throws IllegalArgumentException, MathException
double[]
arrays.
Preconditions:
Collection
must contain
double[]
arrays.double[]
arrays in the
categoryData
collection and each of these arrays must
contain at least two values.
This implementation uses the
commons-math F Distribution implementation
to estimate the exact
p-value, using the formula
p = 1 - cumulativeProbability(F)where
F
is the F value and cumulativeProbability
is the commons-math implementation of the F distribution.anovaPValue
in interface OneWayAnova
categoryData
- Collection
of double[]
arrays each containing data for one categoryIllegalArgumentException
- if the preconditions are not metMathException
- if the statistic can not be computed do to a
convergence or other numerical error.public boolean anovaTest(Collection<double[]> categoryData, double alpha) throws IllegalArgumentException, MathException
Preconditions:
Collection
must contain
double[]
arrays.double[]
arrays in the
categoryData
collection and each of these arrays must
contain at least two values.
This implementation uses the
commons-math F Distribution implementation
to estimate the exact
p-value, using the formula
p = 1 - cumulativeProbability(F)where
F
is the F value and cumulativeProbability
is the commons-math implementation of the F distribution.
True is returned iff the estimated p-value is less than alpha.
anovaTest
in interface OneWayAnova
categoryData
- Collection
of double[]
arrays each containing data for one categoryalpha
- significance level of the testIllegalArgumentException
- if the preconditions are not metMathException
- if the statistic can not be computed do to a
convergence or other numerical error.private OneWayAnovaImpl.AnovaStats anovaStats(Collection<double[]> categoryData) throws IllegalArgumentException, MathException
categoryData
- Collection
of double[]
arrays each containing data for one categoryIllegalArgumentException
- if categoryData does not meet
preconditions specified in the interface definitionMathException
- if an error occurs computing the Anova statsCopyright (c) 2003-2014 Apache Software Foundation