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 junit.framework.TestCase;
19:
20: /**
21: * Test cases for the {@link UnivariateStatistic} class.
22: * @version $Revision: 155427 $ $Date: 2005-02-26 06:11:52 -0700 (Sat, 26 Feb 2005) $
23: */
24: public abstract class UnivariateStatisticAbstractTest extends TestCase {
25:
26: protected double mean = 12.404545454545455d;
27: protected double geoMean = 12.070589161633011d;
28:
29: protected double var = 10.00235930735931d;
30: protected double std = Math.sqrt(var);
31: protected double skew = 1.437423729196190d;
32: protected double kurt = 2.377191264804700d;
33:
34: protected double min = 8.2d;
35: protected double max = 21d;
36: protected double median = 12d;
37: protected double percentile5 = 8.29d;
38: protected double percentile95 = 20.82d;
39:
40: protected double product = 628096400563833396009676.9200400128d;
41: protected double sumLog = 54.7969806116451507d;
42: protected double sumSq = 3595.250d;
43: protected double sum = 272.90d;
44: protected double secondMoment = 210.04954545454547d;
45: protected double thirdMoment = 868.0906859504136;
46: protected double fourthMoment = 9244.080993773481;
47:
48: protected double tolerance = 10E-12;
49:
50: protected double[] testArray = { 12.5, 12, 11.8, 14.2, 14.9, 14.5,
51: 21, 8.2, 10.3, 11.3, 14.1, 9.9, 12.2, 12, 12.1, 11, 19.8,
52: 11, 10, 8.8, 9, 12.3 };
53:
54: public UnivariateStatisticAbstractTest(String name) {
55: super (name);
56: }
57:
58: public abstract UnivariateStatistic getUnivariateStatistic();
59:
60: public abstract double expectedValue();
61:
62: public double getTolerance() {
63: return tolerance;
64: }
65:
66: public void testEvaluation() throws Exception {
67: assertEquals(expectedValue(), getUnivariateStatistic()
68: .evaluate(testArray), getTolerance());
69: }
70:
71: }
|