Class OneWayAnova

java.lang.Object
org.apache.commons.statistics.inference.OneWayAnova

public final class OneWayAnova extends Object
Implements one-way ANOVA (analysis of variance) statistics.

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 Classes
    Modifier and Type
    Class
    Description
    static final class 
    Result for the one-way ANOVA.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    Return an instance using the default options.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • withDefaults

      public static OneWayAnova withDefaults()
      Return an instance using the default options.
      Returns:
      default instance
    • statistic

      public 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.

      Special cases:

      • If the value in each category is the same (no variance within groups) but different between groups, the f-value is infinity.
      • If the value in every group is the same (no variance within or between groups), the f-value is NaN.
      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

      public OneWayAnova.Result 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.

      Special cases:

      • If the value in each category is the same (no variance within groups) but different between groups, the f-value is infinity and the p-value is zero.
      • If the value in every group is the same (no variance within or between groups), the f-value and p-value are NaN.
      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)