org.apache.commons.math.stat.inference
Class OneWayAnovaImpl

java.lang.Object
  extended by org.apache.commons.math.stat.inference.OneWayAnovaImpl
All Implemented Interfaces:
OneWayAnova

public class OneWayAnovaImpl
extends Object
implements 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
Version:
$Revision: 670469 $ $Date: 2008-06-23 10:01:38 +0200 (lun, 23 jun 2008) $

Constructor Summary
OneWayAnovaImpl()
          Default constructor.
 
Method Summary
 double anovaFValue(Collection<double[]> categoryData)
          Computes the ANOVA F-value for a collection of double[] arrays. This implementation computes the F statistic using the definitional formula F = msbg/mswg where msbg = between group mean square mswg = within group mean square are as defined here
 double anovaPValue(Collection<double[]> categoryData)
          Computes the ANOVA P-value for a collection of double[] arrays. 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.
 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. 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OneWayAnovaImpl

public OneWayAnovaImpl()
Default constructor.

Method Detail

anovaFValue

public double anovaFValue(Collection<double[]> categoryData)
                   throws IllegalArgumentException,
                          MathException
Computes the ANOVA F-value for a collection of double[] arrays.

Preconditions:

This implementation computes the F statistic using the definitional formula

   F = msbg/mswg
where
  msbg = between group mean square
  mswg = within group mean square
are as defined here

Specified by:
anovaFValue in interface OneWayAnova
Parameters:
categoryData - Collection of double[] arrays each containing data for one category
Returns:
Fvalue
Throws:
IllegalArgumentException - if the preconditions are not met
MathException - if the statistic can not be computed do to a convergence or other numerical error.

anovaPValue

public double anovaPValue(Collection<double[]> categoryData)
                   throws IllegalArgumentException,
                          MathException
Computes the ANOVA P-value for a collection of double[] arrays.

Preconditions:

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.

Specified by:
anovaPValue in interface OneWayAnova
Parameters:
categoryData - Collection of double[] arrays each containing data for one category
Returns:
Pvalue
Throws:
IllegalArgumentException - if the preconditions are not met
MathException - if the statistic can not be computed do to a convergence or other numerical error.

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:

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.

Specified by:
anovaTest in interface OneWayAnova
Parameters:
categoryData - Collection of double[] arrays each containing data for one category
alpha - 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 met
MathException - if the statistic can not be computed do to a convergence or other numerical error.


Copyright © 2003-2008 The Apache Software Foundation. All Rights Reserved.