1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.math.stat.inference;
18
19 import java.util.Collection;
20 import org.apache.commons.math.MathException;
21 import org.apache.commons.math.stat.descriptive.StatisticalSummary;
22
23
24
25
26
27
28
29
30 public class TestUtils {
31
32
33
34 protected TestUtils() {
35 super();
36 }
37
38
39 private static TTest tTest = new TTestImpl();
40
41
42 private static ChiSquareTest chiSquareTest =
43 new ChiSquareTestImpl();
44
45
46 private static UnknownDistributionChiSquareTest unknownDistributionChiSquareTest =
47 new ChiSquareTestImpl();
48
49
50 private static OneWayAnova oneWayAnova =
51 new OneWayAnovaImpl();
52
53
54
55
56
57
58
59 public static void setChiSquareTest(TTest tTest) {
60 TestUtils.tTest = tTest;
61 }
62
63
64
65
66
67
68 public static TTest getTTest() {
69 return tTest;
70 }
71
72
73
74
75
76
77
78 public static void setChiSquareTest(ChiSquareTest chiSquareTest) {
79 TestUtils.chiSquareTest = chiSquareTest;
80 }
81
82
83
84
85
86
87 public static ChiSquareTest getChiSquareTest() {
88 return chiSquareTest;
89 }
90
91
92
93
94
95
96
97 public static void setUnknownDistributionChiSquareTest(UnknownDistributionChiSquareTest unknownDistributionChiSquareTest) {
98 TestUtils.unknownDistributionChiSquareTest = unknownDistributionChiSquareTest;
99 }
100
101
102
103
104
105
106 public static UnknownDistributionChiSquareTest getUnknownDistributionChiSquareTest() {
107 return unknownDistributionChiSquareTest;
108 }
109
110
111
112
113
114
115
116 public static void setOneWayAnova(OneWayAnova oneWayAnova) {
117 TestUtils.oneWayAnova = oneWayAnova;
118 }
119
120
121
122
123
124
125
126 public static OneWayAnova getOneWayAnova() {
127 return oneWayAnova;
128 }
129
130
131
132
133
134
135
136 public static double homoscedasticT(double[] sample1, double[] sample2)
137 throws IllegalArgumentException {
138 return tTest.homoscedasticT(sample1, sample2);
139 }
140
141
142
143
144 public static double homoscedasticT(StatisticalSummary sampleStats1,
145 StatisticalSummary sampleStats2)
146 throws IllegalArgumentException {
147 return tTest.homoscedasticT(sampleStats1, sampleStats2);
148 }
149
150
151
152
153 public static boolean homoscedasticTTest(double[] sample1, double[] sample2,
154 double alpha)
155 throws IllegalArgumentException, MathException {
156 return tTest. homoscedasticTTest(sample1, sample2, alpha);
157 }
158
159
160
161
162 public static double homoscedasticTTest(double[] sample1, double[] sample2)
163 throws IllegalArgumentException, MathException {
164 return tTest.homoscedasticTTest(sample1, sample2);
165 }
166
167
168
169
170 public static double homoscedasticTTest(StatisticalSummary sampleStats1,
171 StatisticalSummary sampleStats2)
172 throws IllegalArgumentException, MathException {
173 return tTest.homoscedasticTTest(sampleStats1, sampleStats2);
174 }
175
176
177
178
179 public static double pairedT(double[] sample1, double[] sample2)
180 throws IllegalArgumentException, MathException {
181 return tTest.pairedT(sample1, sample2);
182 }
183
184
185
186
187 public static boolean pairedTTest(double[] sample1, double[] sample2,
188 double alpha)
189 throws IllegalArgumentException, MathException {
190 return tTest.pairedTTest(sample1, sample2, alpha);
191 }
192
193
194
195
196 public static double pairedTTest(double[] sample1, double[] sample2)
197 throws IllegalArgumentException, MathException {
198 return tTest.pairedTTest(sample1, sample2);
199 }
200
201
202
203
204 public static double t(double mu, double[] observed)
205 throws IllegalArgumentException {
206 return tTest.t(mu, observed);
207 }
208
209
210
211
212 public static double t(double mu, StatisticalSummary sampleStats)
213 throws IllegalArgumentException {
214 return tTest.t(mu, sampleStats);
215 }
216
217
218
219
220 public static double t(double[] sample1, double[] sample2)
221 throws IllegalArgumentException {
222 return tTest.t(sample1, sample2);
223 }
224
225
226
227
228 public static double t(StatisticalSummary sampleStats1,
229 StatisticalSummary sampleStats2)
230 throws IllegalArgumentException {
231 return tTest.t(sampleStats1, sampleStats2);
232 }
233
234
235
236
237 public static boolean tTest(double mu, double[] sample, double alpha)
238 throws IllegalArgumentException, MathException {
239 return tTest.tTest(mu, sample, alpha);
240 }
241
242
243
244
245 public static double tTest(double mu, double[] sample)
246 throws IllegalArgumentException, MathException {
247 return tTest.tTest(mu, sample);
248 }
249
250
251
252
253 public static boolean tTest(double mu, StatisticalSummary sampleStats,
254 double alpha)
255 throws IllegalArgumentException, MathException {
256 return tTest. tTest(mu, sampleStats, alpha);
257 }
258
259
260
261
262 public static double tTest(double mu, StatisticalSummary sampleStats)
263 throws IllegalArgumentException, MathException {
264 return tTest.tTest(mu, sampleStats);
265 }
266
267
268
269
270 public static boolean tTest(double[] sample1, double[] sample2, double alpha)
271 throws IllegalArgumentException, MathException {
272 return tTest.tTest(sample1, sample2, alpha);
273 }
274
275
276
277
278 public static double tTest(double[] sample1, double[] sample2)
279 throws IllegalArgumentException, MathException {
280 return tTest.tTest(sample1, sample2);
281 }
282
283
284
285
286 public static boolean tTest(StatisticalSummary sampleStats1,
287 StatisticalSummary sampleStats2, double alpha)
288 throws IllegalArgumentException, MathException {
289 return tTest. tTest(sampleStats1, sampleStats2, alpha);
290 }
291
292
293
294
295 public static double tTest(StatisticalSummary sampleStats1,
296 StatisticalSummary sampleStats2)
297 throws IllegalArgumentException, MathException {
298 return tTest.tTest(sampleStats1, sampleStats2);
299 }
300
301
302
303
304 public static double chiSquare(double[] expected, long[] observed)
305 throws IllegalArgumentException {
306 return chiSquareTest.chiSquare(expected, observed);
307 }
308
309
310
311
312 public static double chiSquare(long[][] counts)
313 throws IllegalArgumentException {
314 return chiSquareTest.chiSquare(counts);
315 }
316
317
318
319
320 public static boolean chiSquareTest(double[] expected, long[] observed,
321 double alpha)
322 throws IllegalArgumentException, MathException {
323 return chiSquareTest.chiSquareTest(expected, observed, alpha);
324 }
325
326
327
328
329 public static double chiSquareTest(double[] expected, long[] observed)
330 throws IllegalArgumentException, MathException {
331 return chiSquareTest.chiSquareTest(expected, observed);
332 }
333
334
335
336
337 public static boolean chiSquareTest(long[][] counts, double alpha)
338 throws IllegalArgumentException, MathException {
339 return chiSquareTest. chiSquareTest(counts, alpha);
340 }
341
342
343
344
345 public static double chiSquareTest(long[][] counts)
346 throws IllegalArgumentException, MathException {
347 return chiSquareTest. chiSquareTest(counts);
348 }
349
350
351
352
353
354
355 public static double chiSquareDataSetsComparison(long[] observed1, long[] observed2)
356 throws IllegalArgumentException {
357 return unknownDistributionChiSquareTest.chiSquareDataSetsComparison(observed1, observed2);
358 }
359
360
361
362
363
364
365 public static double chiSquareTestDataSetsComparison(long[] observed1, long[] observed2)
366 throws IllegalArgumentException, MathException {
367 return unknownDistributionChiSquareTest.chiSquareTestDataSetsComparison(observed1, observed2);
368 }
369
370
371
372
373
374
375
376 public static boolean chiSquareTestDataSetsComparison(long[] observed1, long[] observed2,
377 double alpha)
378 throws IllegalArgumentException, MathException {
379 return unknownDistributionChiSquareTest.chiSquareTestDataSetsComparison(observed1, observed2, alpha);
380 }
381
382
383
384
385
386
387 public static double oneWayAnovaFValue(Collection<double[]> categoryData)
388 throws IllegalArgumentException, MathException {
389 return oneWayAnova.anovaFValue(categoryData);
390 }
391
392
393
394
395
396
397 public static double oneWayAnovaPValue(Collection<double[]> categoryData)
398 throws IllegalArgumentException, MathException {
399 return oneWayAnova.anovaPValue(categoryData);
400 }
401
402
403
404
405
406
407 public static boolean oneWayAnovaTest(Collection<double[]> categoryData, double alpha)
408 throws IllegalArgumentException, MathException {
409 return oneWayAnova.anovaTest(categoryData, alpha);
410 }
411
412
413
414 }