Home | History | Annotate | Download | only in inference
      1 /*
      2  * Licensed to the Apache Software Foundation (ASF) under one or more
      3  * contributor license agreements.  See the NOTICE file distributed with
      4  * this work for additional information regarding copyright ownership.
      5  * The ASF licenses this file to You under the Apache License, Version 2.0
      6  * (the "License"); you may not use this file except in compliance with
      7  * the License.  You may obtain a copy of the License at
      8  *
      9  *      http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  */
     17 package org.apache.commons.math.stat.inference;
     18 
     19 import org.apache.commons.math.MathException;
     20 import java.util.Collection;
     21 
     22 /**
     23  * An interface for one-way ANOVA (analysis of variance).
     24  *
     25  * <p> Tests for differences between two or more categories of univariate data
     26  * (for example, the body mass index of accountants, lawyers, doctors and
     27  * computer programmers).  When two categories are given, this is equivalent to
     28  * the {@link org.apache.commons.math.stat.inference.TTest}.
     29  * </p>
     30  *
     31  * @since 1.2
     32  * @version $Revision: 811786 $ $Date: 2009-09-06 11:36:08 +0200 (dim. 06 sept. 2009) $
     33  */
     34 public interface OneWayAnova {
     35 
     36     /**
     37      * Computes the ANOVA F-value for a collection of <code>double[]</code>
     38      * arrays.
     39      *
     40      * <p><strong>Preconditions</strong>: <ul>
     41      * <li>The categoryData <code>Collection</code> must contain
     42      * <code>double[]</code> arrays.</li>
     43      * <li> There must be at least two <code>double[]</code> arrays in the
     44      * <code>categoryData</code> collection and each of these arrays must
     45      * contain at least two values.</li></ul></p>
     46      *
     47      * @param categoryData <code>Collection</code> of <code>double[]</code>
     48      * arrays each containing data for one category
     49      * @return Fvalue
     50      * @throws IllegalArgumentException if the preconditions are not met
     51      * @throws MathException if the statistic can not be computed do to a
     52      *         convergence or other numerical error.
     53      */
     54     double anovaFValue(Collection<double[]> categoryData)
     55         throws IllegalArgumentException, MathException;
     56 
     57     /**
     58      * Computes the ANOVA P-value for a collection of <code>double[]</code>
     59      * arrays.
     60      *
     61      * <p><strong>Preconditions</strong>: <ul>
     62      * <li>The categoryData <code>Collection</code> must contain
     63      * <code>double[]</code> arrays.</li>
     64      * <li> There must be at least two <code>double[]</code> arrays in the
     65      * <code>categoryData</code> collection and each of these arrays must
     66      * contain at least two values.</li></ul></p>
     67      *
     68      * @param categoryData <code>Collection</code> of <code>double[]</code>
     69      * arrays each containing data for one category
     70      * @return Pvalue
     71      * @throws IllegalArgumentException if the preconditions are not met
     72      * @throws MathException if the statistic can not be computed do to a
     73      *         convergence or other numerical error.
     74      */
     75     double anovaPValue(Collection<double[]> categoryData)
     76         throws IllegalArgumentException, MathException;
     77 
     78     /**
     79      * Performs an ANOVA test, evaluating the null hypothesis that there
     80      * is no difference among the means of the data categories.
     81      *
     82      * <p><strong>Preconditions</strong>: <ul>
     83      * <li>The categoryData <code>Collection</code> must contain
     84      * <code>double[]</code> arrays.</li>
     85      * <li> There must be at least two <code>double[]</code> arrays in the
     86      * <code>categoryData</code> collection and each of these arrays must
     87      * contain at least two values.</li>
     88      * <li>alpha must be strictly greater than 0 and less than or equal to 0.5.
     89      * </li></ul></p>
     90      *
     91      * @param categoryData <code>Collection</code> of <code>double[]</code>
     92      * arrays each containing data for one category
     93      * @param alpha significance level of the test
     94      * @return true if the null hypothesis can be rejected with
     95      * confidence 1 - alpha
     96      * @throws IllegalArgumentException if the preconditions are not met
     97      * @throws MathException if the statistic can not be computed do to a
     98      *         convergence or other numerical error.
     99      */
    100     boolean anovaTest(Collection<double[]> categoryData, double alpha)
    101         throws IllegalArgumentException, MathException;
    102 
    103 }
    104