001: /*
002: * Copyright 2005 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.apache.commons.math.stat.inference;
017:
018: import org.apache.commons.math.MathException;
019: import org.apache.commons.math.stat.descriptive.StatisticalSummary;
020:
021: /**
022: * A collection of static methods to create inference test instances or to
023: * perform inference tests.
024: *
025: * @since 1.1
026: * @version $Revision: 209144 $ $Date: 2005-07-04 16:30:05 -0700 (Mon, 04 Jul 2005) $
027: */
028: public class TestUtils {
029: /**
030: * Prevent instantiation.
031: */
032: protected TestUtils() {
033: super ();
034: }
035:
036: /** Singleton TTest instance initialized using configured factory */
037: private static TTest tTest = TestFactory.newInstance()
038: .createTTest();
039:
040: /** Singleton ChiSquareTest instance initialized using configured factory */
041: private static ChiSquareTest chiSquareTest = TestFactory
042: .newInstance().createChiSquareTest();
043:
044: /**
045: * Return a (singleton) TTest instance. Does not create a new instance.
046: *
047: * @return a TTest instance
048: */
049: public static TTest getTTest() {
050: return tTest;
051: }
052:
053: /**
054: * Return a (singleton) ChiSquareTest instance. Does not create a new instance.
055: *
056: * @return a ChiSquareTest instance
057: */
058: public static ChiSquareTest getChiSquareTest() {
059: return chiSquareTest;
060: }
061:
062: /**
063: * @see org.apache.commons.math.stat.inference.TTest#homoscedasticT(double[], double[])
064: */
065: public static double homoscedasticT(double[] sample1,
066: double[] sample2) throws IllegalArgumentException {
067: return tTest.homoscedasticT(sample1, sample2);
068: }
069:
070: /**
071: * @see org.apache.commons.math.stat.inference.TTest#homoscedasticT(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary)
072: */
073: public static double homoscedasticT(
074: StatisticalSummary sampleStats1,
075: StatisticalSummary sampleStats2)
076: throws IllegalArgumentException {
077: return tTest.homoscedasticT(sampleStats1, sampleStats2);
078: }
079:
080: /**
081: * @see org.apache.commons.math.stat.inference.TTest#homoscedasticTTest(double[], double[], double)
082: */
083: public static boolean homoscedasticTTest(double[] sample1,
084: double[] sample2, double alpha)
085: throws IllegalArgumentException, MathException {
086: return tTest.homoscedasticTTest(sample1, sample2, alpha);
087: }
088:
089: /**
090: * @see org.apache.commons.math.stat.inference.TTest#homoscedasticTTest(double[], double[])
091: */
092: public static double homoscedasticTTest(double[] sample1,
093: double[] sample2) throws IllegalArgumentException,
094: MathException {
095: return tTest.homoscedasticTTest(sample1, sample2);
096: }
097:
098: /**
099: * @see org.apache.commons.math.stat.inference.TTest#homoscedasticTTest(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary)
100: */
101: public static double homoscedasticTTest(
102: StatisticalSummary sampleStats1,
103: StatisticalSummary sampleStats2)
104: throws IllegalArgumentException, MathException {
105: return tTest.homoscedasticTTest(sampleStats1, sampleStats2);
106: }
107:
108: /**
109: * @see org.apache.commons.math.stat.inference.TTest#pairedT(double[], double[])
110: */
111: public static double pairedT(double[] sample1, double[] sample2)
112: throws IllegalArgumentException, MathException {
113: return tTest.pairedT(sample1, sample2);
114: }
115:
116: /**
117: * @see org.apache.commons.math.stat.inference.TTest#pairedTTest(double[], double[], double)
118: */
119: public static boolean pairedTTest(double[] sample1,
120: double[] sample2, double alpha)
121: throws IllegalArgumentException, MathException {
122: return tTest.pairedTTest(sample1, sample2, alpha);
123: }
124:
125: /**
126: * @see org.apache.commons.math.stat.inference.TTest#pairedTTest(double[], double[])
127: */
128: public static double pairedTTest(double[] sample1, double[] sample2)
129: throws IllegalArgumentException, MathException {
130: return tTest.pairedTTest(sample1, sample2);
131: }
132:
133: /**
134: * @see org.apache.commons.math.stat.inference.TTest#t(double, double[])
135: */
136: public static double t(double mu, double[] observed)
137: throws IllegalArgumentException {
138: return tTest.t(mu, observed);
139: }
140:
141: /**
142: * @see org.apache.commons.math.stat.inference.TTest#t(double, org.apache.commons.math.stat.descriptive.StatisticalSummary)
143: */
144: public static double t(double mu, StatisticalSummary sampleStats)
145: throws IllegalArgumentException {
146: return tTest.t(mu, sampleStats);
147: }
148:
149: /**
150: * @see org.apache.commons.math.stat.inference.TTest#t(double[], double[])
151: */
152: public static double t(double[] sample1, double[] sample2)
153: throws IllegalArgumentException {
154: return tTest.t(sample1, sample2);
155: }
156:
157: /**
158: * @see org.apache.commons.math.stat.inference.TTest#t(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary)
159: */
160: public static double t(StatisticalSummary sampleStats1,
161: StatisticalSummary sampleStats2)
162: throws IllegalArgumentException {
163: return tTest.t(sampleStats1, sampleStats2);
164: }
165:
166: /**
167: * @see org.apache.commons.math.stat.inference.TTest#tTest(double, double[], double)
168: */
169: public static boolean tTest(double mu, double[] sample, double alpha)
170: throws IllegalArgumentException, MathException {
171: return tTest.tTest(mu, sample, alpha);
172: }
173:
174: /**
175: * @see org.apache.commons.math.stat.inference.TTest#tTest(double, double[])
176: */
177: public static double tTest(double mu, double[] sample)
178: throws IllegalArgumentException, MathException {
179: return tTest.tTest(mu, sample);
180: }
181:
182: /**
183: * @see org.apache.commons.math.stat.inference.TTest#tTest(double, org.apache.commons.math.stat.descriptive.StatisticalSummary, double)
184: */
185: public static boolean tTest(double mu,
186: StatisticalSummary sampleStats, double alpha)
187: throws IllegalArgumentException, MathException {
188: return tTest.tTest(mu, sampleStats, alpha);
189: }
190:
191: /**
192: * @see org.apache.commons.math.stat.inference.TTest#tTest(double, org.apache.commons.math.stat.descriptive.StatisticalSummary)
193: */
194: public static double tTest(double mu, StatisticalSummary sampleStats)
195: throws IllegalArgumentException, MathException {
196: return tTest.tTest(mu, sampleStats);
197: }
198:
199: /**
200: * @see org.apache.commons.math.stat.inference.TTest#tTest(double[], double[], double)
201: */
202: public static boolean tTest(double[] sample1, double[] sample2,
203: double alpha) throws IllegalArgumentException,
204: MathException {
205: return tTest.tTest(sample1, sample2, alpha);
206: }
207:
208: /**
209: * @see org.apache.commons.math.stat.inference.TTest#tTest(double[], double[])
210: */
211: public static double tTest(double[] sample1, double[] sample2)
212: throws IllegalArgumentException, MathException {
213: return tTest.tTest(sample1, sample2);
214: }
215:
216: /**
217: * @see org.apache.commons.math.stat.inference.TTest#tTest(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary, double)
218: */
219: public static boolean tTest(StatisticalSummary sampleStats1,
220: StatisticalSummary sampleStats2, double alpha)
221: throws IllegalArgumentException, MathException {
222: return tTest.tTest(sampleStats1, sampleStats2, alpha);
223: }
224:
225: /**
226: * @see org.apache.commons.math.stat.inference.TTest#tTest(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary)
227: */
228: public static double tTest(StatisticalSummary sampleStats1,
229: StatisticalSummary sampleStats2)
230: throws IllegalArgumentException, MathException {
231: return tTest.tTest(sampleStats1, sampleStats2);
232: }
233:
234: /**
235: * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquare(double[], long[])
236: */
237: public static double chiSquare(double[] expected, long[] observed)
238: throws IllegalArgumentException {
239: return chiSquareTest.chiSquare(expected, observed);
240: }
241:
242: /**
243: * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquare(long[][])
244: */
245: public static double chiSquare(long[][] counts)
246: throws IllegalArgumentException {
247: return chiSquareTest.chiSquare(counts);
248: }
249:
250: /**
251: * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquareTest(double[], long[], double)
252: */
253: public static boolean chiSquareTest(double[] expected,
254: long[] observed, double alpha)
255: throws IllegalArgumentException, MathException {
256: return chiSquareTest.chiSquareTest(expected, observed, alpha);
257: }
258:
259: /**
260: * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquareTest(double[], long[])
261: */
262: public static double chiSquareTest(double[] expected,
263: long[] observed) throws IllegalArgumentException,
264: MathException {
265: return chiSquareTest.chiSquareTest(expected, observed);
266: }
267:
268: /**
269: * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquareTest(long[][], double)
270: */
271: public static boolean chiSquareTest(long[][] counts, double alpha)
272: throws IllegalArgumentException, MathException {
273: return chiSquareTest.chiSquareTest(counts, alpha);
274: }
275:
276: /**
277: * @see org.apache.commons.math.stat.inference.ChiSquareTest#chiSquareTest(long[][])
278: */
279: public static double chiSquareTest(long[][] counts)
280: throws IllegalArgumentException, MathException {
281: return chiSquareTest.chiSquareTest(counts);
282: }
283:
284: }
|