1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.math.stat.descriptive;
18
19 import org.apache.commons.math.stat.descriptive.moment.FourthMoment;
20 import org.apache.commons.math.stat.descriptive.moment.Kurtosis;
21 import org.apache.commons.math.stat.descriptive.moment.Mean;
22 import org.apache.commons.math.stat.descriptive.moment.Skewness;
23 import org.apache.commons.math.stat.descriptive.moment.Variance;
24
25 import junit.framework.TestCase;
26
27
28
29
30 public class InteractionTest extends TestCase {
31
32 protected double mean = 12.40454545454550;
33 protected double var = 10.00235930735930;
34 protected double skew = 1.437423729196190;
35 protected double kurt = 2.377191264804700;
36
37 protected double tolerance = 10E-12;
38
39 protected double[] testArray =
40 {
41 12.5,
42 12,
43 11.8,
44 14.2,
45 14.9,
46 14.5,
47 21,
48 8.2,
49 10.3,
50 11.3,
51 14.1,
52 9.9,
53 12.2,
54 12,
55 12.1,
56 11,
57 19.8,
58 11,
59 10,
60 8.8,
61 9,
62 12.3 };
63
64 public InteractionTest(String name) {
65 super(name);
66 }
67
68
69 public void testInteraction() {
70
71 FourthMoment m4 = new FourthMoment();
72 Mean m = new Mean(m4);
73 Variance v = new Variance(m4);
74 Skewness s= new Skewness(m4);
75 Kurtosis k = new Kurtosis(m4);
76
77 for (int i = 0; i < testArray.length; i++){
78 m4.increment(testArray[i]);
79 }
80
81 assertEquals(mean,m.getResult(),tolerance);
82 assertEquals(var,v.getResult(),tolerance);
83 assertEquals(skew ,s.getResult(),tolerance);
84 assertEquals(kurt,k.getResult(),tolerance);
85
86 }
87
88 }