View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
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  }