01: /*
02: * Copyright 2003-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.descriptive.moment;
17:
18: import junit.framework.Test;
19: import junit.framework.TestSuite;
20:
21: import org.apache.commons.math.stat.descriptive.StorelessUnivariateStatisticAbstractTest;
22: import org.apache.commons.math.stat.descriptive.UnivariateStatistic;
23:
24: /**
25: * Test cases for the {@link UnivariateStatistic} class.
26: *
27: * @version $Revision: 155427 $ $Date: 2005-02-26 06:11:52 -0700 (Sat, 26 Feb 2005) $
28: */
29: public class SkewnessTest extends
30: StorelessUnivariateStatisticAbstractTest {
31:
32: protected Skewness stat;
33:
34: /**
35: * @param name
36: */
37: public SkewnessTest(String name) {
38: super (name);
39: }
40:
41: /* (non-Javadoc)
42: * @see org.apache.commons.math.stat.descriptive.UnivariateStatisticAbstractTest#getUnivariateStatistic()
43: */
44: public UnivariateStatistic getUnivariateStatistic() {
45: return new Skewness();
46: }
47:
48: public static Test suite() {
49: TestSuite suite = new TestSuite(SkewnessTest.class);
50: suite.setName("Skewness Tests");
51: return suite;
52: }
53:
54: /* (non-Javadoc)
55: * @see org.apache.commons.math.stat.descriptive.UnivariateStatisticAbstractTest#expectedValue()
56: */
57: public double expectedValue() {
58: return this .skew;
59: }
60:
61: /**
62: * Make sure Double.NaN is returned iff n < 3
63: *
64: */
65: public void testNaN() {
66: Skewness skew = new Skewness();
67: assertTrue(Double.isNaN(skew.getResult()));
68: skew.increment(1d);
69: assertTrue(Double.isNaN(skew.getResult()));
70: skew.increment(1d);
71: assertTrue(Double.isNaN(skew.getResult()));
72: skew.increment(1d);
73: assertFalse(Double.isNaN(skew.getResult()));
74: }
75:
76: }
|