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$ $Date$
33 */
34 public interface OneWayAnova {
35 /**
36 * Computes the ANOVA F-value for a collection of <code>double[]</code>
37 * arrays.
38 *
39 * <p><strong>Preconditions</strong>: <ul>
40 * <li>The categoryData <code>Collection</code> must contain
41 * <code>double[]</code> arrays.</li>
42 * <li> There must be at least two <code>double[]</code> arrays in the
43 * <code>categoryData</code> collection and each of these arrays must
44 * contain at least two values.</li></ul></p>
45 *
46 * @param categoryData <code>Collection</code> of <code>double[]</code>
47 * arrays each containing data for one category
48 * @return Fvalue
49 * @throws IllegalArgumentException if the preconditions are not met
50 * @throws MathException if the statistic can not be computed do to a
51 * convergence or other numerical error.
52 */
53 public double anovaFValue(Collection categoryData)
54 throws IllegalArgumentException, MathException;
55
56 /**
57 * Computes the ANOVA P-value for a collection of <code>double[]</code>
58 * arrays.
59 *
60 * <p><strong>Preconditions</strong>: <ul>
61 * <li>The categoryData <code>Collection</code> must contain
62 * <code>double[]</code> arrays.</li>
63 * <li> There must be at least two <code>double[]</code> arrays in the
64 * <code>categoryData</code> collection and each of these arrays must
65 * contain at least two values.</li></ul></p>
66 *
67 * @param categoryData <code>Collection</code> of <code>double[]</code>
68 * arrays each containing data for one category
69 * @return Pvalue
70 * @throws IllegalArgumentException if the preconditions are not met
71 * @throws MathException if the statistic can not be computed do to a
72 * convergence or other numerical error.
73 */
74 public double anovaPValue(Collection categoryData)
75 throws IllegalArgumentException, MathException;
76
77 /**
78 * Performs an ANOVA test, evaluating the null hypothesis that there
79 * is no difference among the means of the data categories.
80 *
81 * <p><strong>Preconditions</strong>: <ul>
82 * <li>The categoryData <code>Collection</code> must contain
83 * <code>double[]</code> arrays.</li>
84 * <li> There must be at least two <code>double[]</code> arrays in the
85 * <code>categoryData</code> collection and each of these arrays must
86 * contain at least two values.</li>
87 * <li>alpha must be strictly greater than 0 and less than or equal to 0.5.
88 * </li></ul></p>
89 *
90 * @param categoryData <code>Collection</code> of <code>double[]</code>
91 * arrays each containing data for one category
92 * @param alpha significance level of the test
93 * @return true if the null hypothesis can be rejected with
94 * confidence 1 - alpha
95 * @throws IllegalArgumentException if the preconditions are not met
96 * @throws MathException if the statistic can not be computed do to a
97 * convergence or other numerical error.
98 */
99 public boolean anovaTest(Collection categoryData, double alpha)
100 throws IllegalArgumentException, MathException;
101
102 }