Classes in this File | Line Coverage | Branch Coverage | Complexity | |||||||
TestUtils |
|
| 1.0;1 |
1 | /* |
|
2 | * Copyright 2005 The Apache Software Foundation. |
|
3 | * |
|
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | * you may not use this file except in compliance with the License. |
|
6 | * You may obtain a copy of the License at |
|
7 | * |
|
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 | * |
|
10 | * Unless required by applicable law or agreed to in writing, software |
|
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 | * See the License for the specific language governing permissions and |
|
14 | * limitations under the License. |
|
15 | */ |
|
16 | package org.apache.commons.math.stat.inference; |
|
17 | ||
18 | import org.apache.commons.math.MathException; |
|
19 | import org.apache.commons.math.stat.descriptive.StatisticalSummary; |
|
20 | ||
21 | /** |
|
22 | * A collection of static methods to create inference test instances or to |
|
23 | * perform inference tests. |
|
24 | * |
|
25 | * @since 1.1 |
|
26 | * @version $Revision$ $Date: 2005-07-04 16:30:05 -0700 (Mon, 04 Jul 2005) $ |
|
27 | */ |
|
28 | public class TestUtils { |
|
29 | /** |
|
30 | * Prevent instantiation. |
|
31 | */ |
|
32 | protected TestUtils() { |
|
33 | 0 | super(); |
34 | 0 | } |
35 | ||
36 | /** Singleton TTest instance initialized using configured factory */ |
|
37 | 6 | private static TTest tTest = TestFactory.newInstance().createTTest(); |
38 | ||
39 | /** Singleton ChiSquareTest instance initialized using configured factory */ |
|
40 | 6 | private static ChiSquareTest chiSquareTest = |
41 | TestFactory.newInstance().createChiSquareTest(); |
|
42 | ||
43 | /** |
|
44 | * Return a (singleton) TTest instance. Does not create a new instance. |
|
45 | * |
|
46 | * @return a TTest instance |
|
47 | */ |
|
48 | public static TTest getTTest() { |
|
49 | 12 | return tTest; |
50 | } |
|
51 | ||
52 | /** |
|
53 | * Return a (singleton) ChiSquareTest instance. Does not create a new instance. |
|
54 | * |
|
55 | * @return a ChiSquareTest instance |
|
56 | */ |
|
57 | public static ChiSquareTest getChiSquareTest() { |
|
58 | 8 | return chiSquareTest; |
59 | } |
|
60 | ||
61 | /** |
|
62 | * @see org.apache.commons.math.stat.inference.TTest#homoscedasticT(double[], double[]) |
|
63 | */ |
|
64 | public static double homoscedasticT(double[] sample1, double[] sample2) |
|
65 | throws IllegalArgumentException { |
|
66 | 2 | return tTest.homoscedasticT(sample1, sample2); |
67 | } |
|
68 | ||
69 | /** |
|
70 | * @see org.apache.commons.math.stat.inference.TTest#homoscedasticT(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary) |
|
71 | */ |
|
72 | public static double homoscedasticT(StatisticalSummary sampleStats1, |
|
73 | StatisticalSummary sampleStats2) |
|
74 | throws IllegalArgumentException { |
|
75 | 0 | return tTest.homoscedasticT(sampleStats1, sampleStats2); |
76 | } |
|
77 | ||
78 | /** |
|
79 | * @see org.apache.commons.math.stat.inference.TTest#homoscedasticTTest(double[], double[], double) |
|
80 | */ |
|
81 | public static boolean homoscedasticTTest(double[] sample1, double[] sample2, |
|
82 | double alpha) |
|
83 | throws IllegalArgumentException, MathException { |
|
84 | 4 | return tTest. homoscedasticTTest(sample1, sample2, alpha); |
85 | } |
|
86 | ||
87 | /** |
|
88 | * @see org.apache.commons.math.stat.inference.TTest#homoscedasticTTest(double[], double[]) |
|
89 | */ |
|
90 | public static double homoscedasticTTest(double[] sample1, double[] sample2) |
|
91 | throws IllegalArgumentException, MathException { |
|
92 | 0 | return tTest.homoscedasticTTest(sample1, sample2); |
93 | } |
|
94 | ||
95 | /** |
|
96 | * @see org.apache.commons.math.stat.inference.TTest#homoscedasticTTest(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary) |
|
97 | */ |
|
98 | public static double homoscedasticTTest(StatisticalSummary sampleStats1, |
|
99 | StatisticalSummary sampleStats2) |
|
100 | throws IllegalArgumentException, MathException { |
|
101 | 2 | return tTest.homoscedasticTTest(sampleStats1, sampleStats2); |
102 | } |
|
103 | ||
104 | /** |
|
105 | * @see org.apache.commons.math.stat.inference.TTest#pairedT(double[], double[]) |
|
106 | */ |
|
107 | public static double pairedT(double[] sample1, double[] sample2) |
|
108 | throws IllegalArgumentException, MathException { |
|
109 | 2 | return tTest.pairedT(sample1, sample2); |
110 | } |
|
111 | ||
112 | /** |
|
113 | * @see org.apache.commons.math.stat.inference.TTest#pairedTTest(double[], double[], double) |
|
114 | */ |
|
115 | public static boolean pairedTTest(double[] sample1, double[] sample2, |
|
116 | double alpha) |
|
117 | throws IllegalArgumentException, MathException { |
|
118 | 4 | return tTest.pairedTTest(sample1, sample2, alpha); |
119 | } |
|
120 | ||
121 | /** |
|
122 | * @see org.apache.commons.math.stat.inference.TTest#pairedTTest(double[], double[]) |
|
123 | */ |
|
124 | public static double pairedTTest(double[] sample1, double[] sample2) |
|
125 | throws IllegalArgumentException, MathException { |
|
126 | 4 | return tTest.pairedTTest(sample1, sample2); |
127 | } |
|
128 | ||
129 | /** |
|
130 | * @see org.apache.commons.math.stat.inference.TTest#t(double, double[]) |
|
131 | */ |
|
132 | public static double t(double mu, double[] observed) |
|
133 | throws IllegalArgumentException { |
|
134 | 10 | return tTest.t(mu, observed); |
135 | } |
|
136 | ||
137 | /** |
|
138 | * @see org.apache.commons.math.stat.inference.TTest#t(double, org.apache.commons.math.stat.descriptive.StatisticalSummary) |
|
139 | */ |
|
140 | public static double t(double mu, StatisticalSummary sampleStats) |
|
141 | throws IllegalArgumentException { |
|
142 | 10 | return tTest.t(mu, sampleStats); |
143 | } |
|
144 | ||
145 | /** |
|
146 | * @see org.apache.commons.math.stat.inference.TTest#t(double[], double[]) |
|
147 | */ |
|
148 | public static double t(double[] sample1, double[] sample2) |
|
149 | throws IllegalArgumentException { |
|
150 | 6 | return tTest.t(sample1, sample2); |
151 | } |
|
152 | ||
153 | /** |
|
154 | * @see org.apache.commons.math.stat.inference.TTest#t(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary) |
|
155 | */ |
|
156 | public static double t(StatisticalSummary sampleStats1, |
|
157 | StatisticalSummary sampleStats2) |
|
158 | throws IllegalArgumentException { |
|
159 | 4 | return tTest.t(sampleStats1, sampleStats2); |
160 | } |
|
161 | ||
162 | /** |
|
163 | * @see org.apache.commons.math.stat.inference.TTest#tTest(double, double[], double) |
|
164 | */ |
|
165 | public static boolean tTest(double mu, double[] sample, double alpha) |
|
166 | throws IllegalArgumentException, MathException { |
|
167 | 6 | return tTest.tTest(mu, sample, alpha); |
168 | } |
|
169 | ||
170 | /** |
|
171 | * @see org.apache.commons.math.stat.inference.TTest#tTest(double, double[]) |
|
172 | */ |
|
173 | public static double tTest(double mu, double[] sample) |
|
174 | throws IllegalArgumentException, MathException { |
|
175 | 6 | return tTest.tTest(mu, sample); |
176 | } |
|
177 | ||
178 | /** |
|
179 | * @see org.apache.commons.math.stat.inference.TTest#tTest(double, org.apache.commons.math.stat.descriptive.StatisticalSummary, double) |
|
180 | */ |
|
181 | public static boolean tTest(double mu, StatisticalSummary sampleStats, |
|
182 | double alpha) |
|
183 | throws IllegalArgumentException, MathException { |
|
184 | 6 | return tTest. tTest(mu, sampleStats, alpha); |
185 | } |
|
186 | ||
187 | /** |
|
188 | * @see org.apache.commons.math.stat.inference.TTest#tTest(double, org.apache.commons.math.stat.descriptive.StatisticalSummary) |
|
189 | */ |
|
190 | public static double tTest(double mu, StatisticalSummary sampleStats) |
|
191 | throws IllegalArgumentException, MathException { |
|
192 | 6 | return tTest.tTest(mu, sampleStats); |
193 | } |
|
194 | ||
195 | /** |
|
196 | * @see org.apache.commons.math.stat.inference.TTest#tTest(double[], double[], double) |
|
197 | */ |
|
198 | public static boolean tTest(double[] sample1, double[] sample2, double alpha) |
|
199 | throws IllegalArgumentException, MathException { |
|
200 | 8 | return tTest.tTest(sample1, sample2, alpha); |
201 | } |
|
202 | ||
203 | /** |
|
204 | * @see org.apache.commons.math.stat.inference.TTest#tTest(double[], double[]) |
|
205 | */ |
|
206 | public static double tTest(double[] sample1, double[] sample2) |
|
207 | throws IllegalArgumentException, MathException { |
|
208 | 6 | return tTest.tTest(sample1, sample2); |
209 | } |
|
210 | ||
211 | /** |
|
212 | * @see org.apache.commons.math.stat.inference.TTest#tTest(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary, double) |
|
213 | */ |
|
214 | public static boolean tTest(StatisticalSummary sampleStats1, |
|
215 | StatisticalSummary sampleStats2, double alpha) |
|
216 | throws IllegalArgumentException, MathException { |
|
217 | 8 | return tTest. tTest(sampleStats1, sampleStats2, alpha); |
218 | } |
|
219 | ||
220 | /** |
|
221 | * @see org.apache.commons.math.stat.inference.TTest#tTest(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary) |
|
222 | */ |
|
223 | public static double tTest(StatisticalSummary sampleStats1, |
|
224 | StatisticalSummary sampleStats2) |
|
225 | throws IllegalArgumentException, MathException { |
|
226 | 4 | return tTest.tTest(sampleStats1, sampleStats2); |
227 | } |
|
228 | ||
229 | /** |
|
230 | * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquare(double[], long[]) |
|
231 | */ |
|
232 | public static double chiSquare(double[] expected, long[] observed) |
|
233 | throws IllegalArgumentException { |
|
234 | 10 | return chiSquareTest.chiSquare(expected, observed); |
235 | } |
|
236 | ||
237 | /** |
|
238 | * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquare(long[][]) |
|
239 | */ |
|
240 | public static double chiSquare(long[][] counts) |
|
241 | throws IllegalArgumentException { |
|
242 | 14 | return chiSquareTest.chiSquare(counts); |
243 | } |
|
244 | ||
245 | /** |
|
246 | * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquareTest(double[], long[], double) |
|
247 | */ |
|
248 | public static boolean chiSquareTest(double[] expected, long[] observed, |
|
249 | double alpha) |
|
250 | throws IllegalArgumentException, MathException { |
|
251 | 10 | return chiSquareTest.chiSquareTest(expected, observed, alpha); |
252 | } |
|
253 | ||
254 | /** |
|
255 | * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquareTest(double[], long[]) |
|
256 | */ |
|
257 | public static double chiSquareTest(double[] expected, long[] observed) |
|
258 | throws IllegalArgumentException, MathException { |
|
259 | 4 | return chiSquareTest.chiSquareTest(expected, observed); |
260 | } |
|
261 | ||
262 | /** |
|
263 | * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquareTest(long[][], double) |
|
264 | */ |
|
265 | public static boolean chiSquareTest(long[][] counts, double alpha) |
|
266 | throws IllegalArgumentException, MathException { |
|
267 | 8 | return chiSquareTest. chiSquareTest(counts, alpha); |
268 | } |
|
269 | ||
270 | /** |
|
271 | * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquareTest(long[][]) |
|
272 | */ |
|
273 | public static double chiSquareTest(long[][] counts) |
|
274 | throws IllegalArgumentException, MathException { |
|
275 | 6 | return chiSquareTest. chiSquareTest(counts); |
276 | } |
|
277 | ||
278 | } |