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 public static double homoscedasticT(double[] sample1, double[] sample2)
135 throws IllegalArgumentException {
136 return tTest.homoscedasticT(sample1, sample2);
137 }
138
139
140
141
142 public static double homoscedasticT(StatisticalSummary sampleStats1,
143 StatisticalSummary sampleStats2)
144 throws IllegalArgumentException {
145 return tTest.homoscedasticT(sampleStats1, sampleStats2);
146 }
147
148
149
150
151 public static boolean homoscedasticTTest(double[] sample1, double[] sample2,
152 double alpha)
153 throws IllegalArgumentException, MathException {
154 return tTest. homoscedasticTTest(sample1, sample2, alpha);
155 }
156
157
158
159
160 public static double homoscedasticTTest(double[] sample1, double[] sample2)
161 throws IllegalArgumentException, MathException {
162 return tTest.homoscedasticTTest(sample1, sample2);
163 }
164
165
166
167
168 public static double homoscedasticTTest(StatisticalSummary sampleStats1,
169 StatisticalSummary sampleStats2)
170 throws IllegalArgumentException, MathException {
171 return tTest.homoscedasticTTest(sampleStats1, sampleStats2);
172 }
173
174
175
176
177 public static double pairedT(double[] sample1, double[] sample2)
178 throws IllegalArgumentException, MathException {
179 return tTest.pairedT(sample1, sample2);
180 }
181
182
183
184
185 public static boolean pairedTTest(double[] sample1, double[] sample2,
186 double alpha)
187 throws IllegalArgumentException, MathException {
188 return tTest.pairedTTest(sample1, sample2, alpha);
189 }
190
191
192
193
194 public static double pairedTTest(double[] sample1, double[] sample2)
195 throws IllegalArgumentException, MathException {
196 return tTest.pairedTTest(sample1, sample2);
197 }
198
199
200
201
202 public static double t(double mu, double[] observed)
203 throws IllegalArgumentException {
204 return tTest.t(mu, observed);
205 }
206
207
208
209
210 public static double t(double mu, StatisticalSummary sampleStats)
211 throws IllegalArgumentException {
212 return tTest.t(mu, sampleStats);
213 }
214
215
216
217
218 public static double t(double[] sample1, double[] sample2)
219 throws IllegalArgumentException {
220 return tTest.t(sample1, sample2);
221 }
222
223
224
225
226 public static double t(StatisticalSummary sampleStats1,
227 StatisticalSummary sampleStats2)
228 throws IllegalArgumentException {
229 return tTest.t(sampleStats1, sampleStats2);
230 }
231
232
233
234
235 public static boolean tTest(double mu, double[] sample, double alpha)
236 throws IllegalArgumentException, MathException {
237 return tTest.tTest(mu, sample, alpha);
238 }
239
240
241
242
243 public static double tTest(double mu, double[] sample)
244 throws IllegalArgumentException, MathException {
245 return tTest.tTest(mu, sample);
246 }
247
248
249
250
251 public static boolean tTest(double mu, StatisticalSummary sampleStats,
252 double alpha)
253 throws IllegalArgumentException, MathException {
254 return tTest. tTest(mu, sampleStats, alpha);
255 }
256
257
258
259
260 public static double tTest(double mu, StatisticalSummary sampleStats)
261 throws IllegalArgumentException, MathException {
262 return tTest.tTest(mu, sampleStats);
263 }
264
265
266
267
268 public static boolean tTest(double[] sample1, double[] sample2, double alpha)
269 throws IllegalArgumentException, MathException {
270 return tTest.tTest(sample1, sample2, alpha);
271 }
272
273
274
275
276 public static double tTest(double[] sample1, double[] sample2)
277 throws IllegalArgumentException, MathException {
278 return tTest.tTest(sample1, sample2);
279 }
280
281
282
283
284 public static boolean tTest(StatisticalSummary sampleStats1,
285 StatisticalSummary sampleStats2, double alpha)
286 throws IllegalArgumentException, MathException {
287 return tTest. tTest(sampleStats1, sampleStats2, alpha);
288 }
289
290
291
292
293 public static double tTest(StatisticalSummary sampleStats1,
294 StatisticalSummary sampleStats2)
295 throws IllegalArgumentException, MathException {
296 return tTest.tTest(sampleStats1, sampleStats2);
297 }
298
299
300
301
302 public static double chiSquare(double[] expected, long[] observed)
303 throws IllegalArgumentException {
304 return chiSquareTest.chiSquare(expected, observed);
305 }
306
307
308
309
310 public static double chiSquare(long[][] counts)
311 throws IllegalArgumentException {
312 return chiSquareTest.chiSquare(counts);
313 }
314
315
316
317
318 public static boolean chiSquareTest(double[] expected, long[] observed,
319 double alpha)
320 throws IllegalArgumentException, MathException {
321 return chiSquareTest.chiSquareTest(expected, observed, alpha);
322 }
323
324
325
326
327 public static double chiSquareTest(double[] expected, long[] observed)
328 throws IllegalArgumentException, MathException {
329 return chiSquareTest.chiSquareTest(expected, observed);
330 }
331
332
333
334
335 public static boolean chiSquareTest(long[][] counts, double alpha)
336 throws IllegalArgumentException, MathException {
337 return chiSquareTest. chiSquareTest(counts, alpha);
338 }
339
340
341
342
343 public static double chiSquareTest(long[][] counts)
344 throws IllegalArgumentException, MathException {
345 return chiSquareTest. chiSquareTest(counts);
346 }
347
348
349
350
351
352
353 public static double chiSquareDataSetsComparison(long[] observed1, long[] observed2)
354 throws IllegalArgumentException {
355 return unknownDistributionChiSquareTest.chiSquareDataSetsComparison(observed1, observed2);
356 }
357
358
359
360
361
362
363 public static double chiSquareTestDataSetsComparison(long[] observed1, long[] observed2)
364 throws IllegalArgumentException, MathException {
365 return unknownDistributionChiSquareTest.chiSquareTestDataSetsComparison(observed1, observed2);
366 }
367
368
369
370
371
372
373
374 public static boolean chiSquareTestDataSetsComparison(long[] observed1, long[] observed2,
375 double alpha)
376 throws IllegalArgumentException, MathException {
377 return unknownDistributionChiSquareTest.chiSquareTestDataSetsComparison(observed1, observed2, alpha);
378 }
379
380
381
382
383
384
385 public static double oneWayAnovaFValue(Collection categoryData)
386 throws IllegalArgumentException, MathException {
387 return oneWayAnova.anovaFValue(categoryData);
388 }
389
390
391
392
393
394
395 public static double oneWayAnovaPValue(Collection categoryData)
396 throws IllegalArgumentException, MathException {
397 return oneWayAnova.anovaPValue(categoryData);
398 }
399
400
401
402
403
404
405 public static boolean oneWayAnovaTest(Collection categoryData, double alpha)
406 throws IllegalArgumentException, MathException {
407 return oneWayAnova.anovaTest(categoryData, alpha);
408 }
409
410 }