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;
17:
18: import org.apache.commons.math.stat.descriptive.moment.FourthMoment;
19: import org.apache.commons.math.stat.descriptive.moment.Kurtosis;
20: import org.apache.commons.math.stat.descriptive.moment.Mean;
21: import org.apache.commons.math.stat.descriptive.moment.Skewness;
22: import org.apache.commons.math.stat.descriptive.moment.Variance;
23:
24: import junit.framework.TestCase;
25:
26: /**
27: * @version $Revision: 155427 $ $Date: 2005-02-26 06:11:52 -0700 (Sat, 26 Feb 2005) $
28: */
29: public class InteractionTest extends TestCase {
30:
31: protected double mean = 12.40454545454550;
32: protected double var = 10.00235930735930;
33: protected double skew = 1.437423729196190;
34: protected double kurt = 2.377191264804700;
35:
36: protected double tolerance = 10E-12;
37:
38: protected double[] testArray = { 12.5, 12, 11.8, 14.2, 14.9, 14.5,
39: 21, 8.2, 10.3, 11.3, 14.1, 9.9, 12.2, 12, 12.1, 11, 19.8,
40: 11, 10, 8.8, 9, 12.3 };
41:
42: public InteractionTest(String name) {
43: super (name);
44: }
45:
46: public void testInteraction() {
47:
48: FourthMoment m4 = new FourthMoment();
49: Mean m = new Mean(m4);
50: Variance v = new Variance(m4);
51: Skewness s = new Skewness(m4);
52: Kurtosis k = new Kurtosis(m4);
53:
54: for (int i = 0; i < testArray.length; i++) {
55: m4.increment(testArray[i]);
56: }
57:
58: assertEquals(mean, m.getResult(), tolerance);
59: assertEquals(var, v.getResult(), tolerance);
60: assertEquals(skew, s.getResult(), tolerance);
61: assertEquals(kurt, k.getResult(), tolerance);
62:
63: }
64:
65: }
|