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