1 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 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 = 39 { 40 12.5, 41 12, 42 11.8, 43 14.2, 44 14.9, 45 14.5, 46 21, 47 8.2, 48 10.3, 49 11.3, 50 14.1, 51 9.9, 52 12.2, 53 12, 54 12.1, 55 11, 56 19.8, 57 11, 58 10, 59 8.8, 60 9, 61 12.3 }; 62 63 public InteractionTest(String name) { 64 super(name); 65 } 66 67 68 public void testInteraction() { 69 70 FourthMoment m4 = new FourthMoment(); 71 Mean m = new Mean(m4); 72 Variance v = new Variance(m4); 73 Skewness s= new Skewness(m4); 74 Kurtosis k = new Kurtosis(m4); 75 76 for (int i = 0; i < testArray.length; i++){ 77 m4.increment(testArray[i]); 78 } 79 80 assertEquals(mean,m.getResult(),tolerance); 81 assertEquals(var,v.getResult(),tolerance); 82 assertEquals(skew ,s.getResult(),tolerance); 83 assertEquals(kurt,k.getResult(),tolerance); 84 85 } 86 87 } 88 | Popular Tags |