001: /*
002: * Copyright 2003-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:
017: package org.apache.commons.math.distribution;
018:
019: import junit.framework.TestCase;
020:
021: /**
022: * @version $Revision: 201916 $ $Date: 2005-06-26 15:25:41 -0700 (Sun, 26 Jun 2005) $
023: */
024: public class DistributionFactoryImplTest extends TestCase {
025: /** */
026: private DistributionFactory factory;
027:
028: /**
029: * Constructor for DistributionFactoryImplTest.
030: * @param name
031: */
032: public DistributionFactoryImplTest(String name) {
033: super (name);
034: }
035:
036: /**
037: * @throws java.lang.Exception
038: */
039: protected void setUp() throws Exception {
040: super .setUp();
041: factory = new DistributionFactoryImpl();
042: }
043:
044: /**
045: * @throws java.lang.Exception
046: */
047: protected void tearDown() throws Exception {
048: factory = null;
049: super .tearDown();
050: }
051:
052: public void testCreateChiSquareDistributionNegative() {
053: try {
054: factory.createChiSquareDistribution(-1.0);
055: fail("negative degrees of freedom. IllegalArgumentException expected");
056: } catch (IllegalArgumentException ex) {
057: ;
058: }
059: }
060:
061: public void testCreateChiSquareDistributionZero() {
062: try {
063: factory.createChiSquareDistribution(0.0);
064: fail("zero degrees of freedom. IllegalArgumentException expected");
065: } catch (IllegalArgumentException ex) {
066: ;
067: }
068: }
069:
070: public void testCreateChiSquareDistributionPositive() {
071: try {
072: factory.createChiSquareDistribution(1.0);
073: } catch (IllegalArgumentException ex) {
074: fail("positive degrees of freedom. IllegalArgumentException is not expected");
075: }
076: }
077:
078: public void testCreateFDistributionNegativePositive() {
079: try {
080: factory.createFDistribution(-1.0, 1.0);
081: fail("negative degrees of freedom. IllegalArgumentException expected");
082: } catch (IllegalArgumentException ex) {
083: ;
084: }
085: }
086:
087: public void testCreateFDistributionZeroPositive() {
088: try {
089: factory.createFDistribution(0.0, 1.0);
090: fail("zero degrees of freedom. IllegalArgumentException expected");
091: } catch (IllegalArgumentException ex) {
092: ;
093: }
094: }
095:
096: public void testCreateFDistributionPositiveNegative() {
097: try {
098: factory.createFDistribution(1.0, -1.0);
099: fail("negative degrees of freedom. IllegalArgumentException expected");
100: } catch (IllegalArgumentException ex) {
101: ;
102: }
103: }
104:
105: public void testCreateFDistributionPositiveZero() {
106: try {
107: factory.createFDistribution(1.0, 0.0);
108: fail("zero degrees of freedom. IllegalArgumentException expected");
109: } catch (IllegalArgumentException ex) {
110: ;
111: }
112: }
113:
114: public void testCreateFDistributionPositivePositive() {
115: try {
116: factory.createFDistribution(1.0, 1.0);
117: } catch (IllegalArgumentException ex) {
118: fail("positive degrees of freedom. IllegalArgumentException is not expected");
119: }
120: }
121:
122: public void testCreateExponentialDistributionNegative() {
123: try {
124: factory.createExponentialDistribution(-1.0);
125: fail("negative mean. IllegalArgumentException expected");
126: } catch (IllegalArgumentException ex) {
127: ;
128: }
129: }
130:
131: public void testCreateExponentialDistributionZero() {
132: try {
133: factory.createExponentialDistribution(0.0);
134: fail("zero mean. IllegalArgumentException expected");
135: } catch (IllegalArgumentException ex) {
136: ;
137: }
138: }
139:
140: public void testCreateExponentialDistributionPositive() {
141: try {
142: factory.createExponentialDistribution(1.0);
143: } catch (IllegalArgumentException ex) {
144: fail("positive mean. IllegalArgumentException is not expected");
145: }
146: }
147:
148: public void testCreateGammaDistributionNegativePositive() {
149: try {
150: factory.createGammaDistribution(-1.0, 1.0);
151: fail("negative alpha. IllegalArgumentException expected");
152: } catch (IllegalArgumentException ex) {
153: ;
154: }
155: }
156:
157: public void testCreateGammaDistributionZeroPositive() {
158: try {
159: factory.createGammaDistribution(0.0, 1.0);
160: fail("zero alpha. IllegalArgumentException expected");
161: } catch (IllegalArgumentException ex) {
162: ;
163: }
164: }
165:
166: public void testCreateGammaDistributionPositiveNegative() {
167: try {
168: factory.createGammaDistribution(1.0, -1.0);
169: fail("negative beta. IllegalArgumentException expected");
170: } catch (IllegalArgumentException ex) {
171: ;
172: }
173: }
174:
175: public void testCreateGammaDistributionPositiveZero() {
176: try {
177: factory.createGammaDistribution(1.0, 0.0);
178: fail("zero beta. IllegalArgumentException expected");
179: } catch (IllegalArgumentException ex) {
180: ;
181: }
182: }
183:
184: public void testCreateGammaDistributionPositivePositive() {
185: try {
186: factory.createGammaDistribution(1.0, 1.0);
187: } catch (IllegalArgumentException ex) {
188: fail("positive alpah and beta. IllegalArgumentException is not expected");
189: }
190: }
191:
192: public void testCreateTDistributionNegative() {
193: try {
194: factory.createTDistribution(-1.0);
195: fail("negative degrees of freedom. IllegalArgumentException expected");
196: } catch (IllegalArgumentException ex) {
197: ;
198: }
199: }
200:
201: public void testCreateTDistributionZero() {
202: try {
203: factory.createTDistribution(0.0);
204: fail("zero degrees of freedom. IllegalArgumentException expected");
205: } catch (IllegalArgumentException ex) {
206: ;
207: }
208: }
209:
210: public void testCreateTDistributionPositive() {
211: try {
212: factory.createTDistribution(1.0);
213: } catch (IllegalArgumentException ex) {
214: fail("positive degrees of freedom. IllegalArgumentException is not expected");
215: }
216: }
217:
218: public void testBinomialDistributionNegativePositive() {
219: try {
220: factory.createBinomialDistribution(-1, 0.5);
221: fail("negative number of trials. IllegalArgumentException expected");
222: } catch (IllegalArgumentException ex) {
223: }
224: }
225:
226: public void testBinomialDistributionZeroPositive() {
227: try {
228: factory.createBinomialDistribution(0, 0.5);
229: } catch (IllegalArgumentException ex) {
230: fail("zero number of trials. IllegalArgumentException is not expected");
231: }
232: }
233:
234: public void testBinomialDistributionPositivePositive() {
235: try {
236: factory.createBinomialDistribution(10, 0.5);
237: } catch (IllegalArgumentException ex) {
238: fail("positive number of trials. IllegalArgumentException is not expected");
239: }
240: }
241:
242: public void testBinomialDistributionPositiveNegative() {
243: try {
244: factory.createBinomialDistribution(10, -0.5);
245: fail("negative probability of success. IllegalArgumentException expected");
246: } catch (IllegalArgumentException ex) {
247: }
248: }
249:
250: public void testBinomialDistributionPositiveZero() {
251: try {
252: factory.createBinomialDistribution(10, 0.0);
253: } catch (IllegalArgumentException ex) {
254: fail("zero probability of success. IllegalArgumentException is not expected");
255: }
256: }
257:
258: public void testBinomialDistributionPositiveOne() {
259: try {
260: factory.createBinomialDistribution(10, 1.0);
261: } catch (IllegalArgumentException ex) {
262: fail("valid probability of success. IllegalArgumentException is not expected");
263: }
264: }
265:
266: public void testBinomialDistributionPositiveTwo() {
267: try {
268: factory.createBinomialDistribution(10, 2.0);
269: fail("high probability of success. IllegalArgumentException expected");
270: } catch (IllegalArgumentException ex) {
271: }
272: }
273:
274: public void testHypergeometricDistributionNegativePositivePositive() {
275: try {
276: factory.createHypergeometricDistribution(-1, 10, 10);
277: fail("negative population size. IllegalArgumentException expected");
278: } catch (IllegalArgumentException ex) {
279: }
280: }
281:
282: public void testHypergeometricDistributionZeroPositivePositive() {
283: try {
284: factory.createHypergeometricDistribution(0, 10, 10);
285: fail("zero population size. IllegalArgumentException expected");
286: } catch (IllegalArgumentException ex) {
287: }
288: }
289:
290: public void testHypergeometricDistributionPositiveNegativePositive() {
291: try {
292: factory.createHypergeometricDistribution(20, -1, 10);
293: fail("negative number of successes. IllegalArgumentException expected");
294: } catch (IllegalArgumentException ex) {
295: }
296: }
297:
298: public void testHypergeometricDistributionPositiveZeroPositive() {
299: try {
300: factory.createHypergeometricDistribution(20, 0, 10);
301: } catch (IllegalArgumentException ex) {
302: fail("valid number of successes. IllegalArgumentException is not expected");
303: }
304: }
305:
306: public void testHypergeometricDistributionPositivePositiveNegative() {
307: try {
308: factory.createHypergeometricDistribution(20, 10, -1);
309: fail("negative sample size. IllegalArgumentException expected");
310: } catch (IllegalArgumentException ex) {
311: }
312: }
313:
314: public void testHypergeometricDistributionPositivePositiveZero() {
315: try {
316: factory.createHypergeometricDistribution(20, 10, 0);
317: } catch (IllegalArgumentException ex) {
318: fail("valid sample size. IllegalArgumentException is not expected");
319: }
320: }
321:
322: public void testHypergeometricDistributionSmallPopulationSize() {
323: try {
324: factory.createHypergeometricDistribution(5, 3, 10);
325: fail("sample size larger than population size. IllegalArgumentException expected");
326: } catch (IllegalArgumentException ex) {
327: }
328: }
329:
330: public void testCauchyDistributionNegative() {
331: try {
332: factory.createCauchyDistribution(0.0, -1.0);
333: fail("invalid scale. IllegalArgumentException expected");
334: } catch (IllegalArgumentException ex) {
335: }
336: }
337:
338: public void testCauchyDistributionZero() {
339: try {
340: factory.createCauchyDistribution(0.0, 0.0);
341: fail("invalid scale. IllegalArgumentException expected");
342: } catch (IllegalArgumentException ex) {
343: }
344: }
345:
346: public void testWeibullDistributionNegativePositive() {
347: try {
348: factory.createWeibullDistribution(-1.0, 1.0);
349: fail("invalid shape. IllegalArgumentException expected");
350: } catch (IllegalArgumentException ex) {
351: }
352: }
353:
354: public void testWeibullDistributionZeroPositive() {
355: try {
356: factory.createWeibullDistribution(0.0, 1.0);
357: fail("invalid shape. IllegalArgumentException expected");
358: } catch (IllegalArgumentException ex) {
359: }
360: }
361:
362: public void testWeibullDistributionPositiveNegative() {
363: try {
364: factory.createWeibullDistribution(1.0, -1.0);
365: fail("invalid scale. IllegalArgumentException expected");
366: } catch (IllegalArgumentException ex) {
367: }
368: }
369:
370: public void testWeibullDistributionPositiveZero() {
371: try {
372: factory.createWeibullDistribution(1.0, 0.0);
373: fail("invalid scale. IllegalArgumentException expected");
374: } catch (IllegalArgumentException ex) {
375: }
376: }
377: }
|