Added tests for second, third, fourth moments.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141340 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1916ebe30a
commit
0ad427869d
|
@ -19,7 +19,7 @@ import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test cases for the {@link UnivariateStatistic} class.
|
* Test cases for the {@link UnivariateStatistic} class.
|
||||||
* @version $Revision: 1.11 $ $Date: 2004/03/21 04:24:17 $
|
* @version $Revision: 1.12 $ $Date: 2004/06/27 19:33:38 $
|
||||||
*/
|
*/
|
||||||
public abstract class UnivariateStatisticAbstractTest extends TestCase {
|
public abstract class UnivariateStatisticAbstractTest extends TestCase {
|
||||||
|
|
||||||
|
@ -41,33 +41,16 @@ public abstract class UnivariateStatisticAbstractTest extends TestCase {
|
||||||
protected double sumLog = 54.7969806116451507d;
|
protected double sumLog = 54.7969806116451507d;
|
||||||
protected double sumSq = 3595.250d;
|
protected double sumSq = 3595.250d;
|
||||||
protected double sum = 272.90d;
|
protected double sum = 272.90d;
|
||||||
|
protected double secondMoment = 210.04954545454547d;
|
||||||
|
protected double thirdMoment = 868.0906859504136;
|
||||||
|
protected double fourthMoment = 9244.080993773481;
|
||||||
|
|
||||||
protected double tolerance = 10E-12;
|
protected double tolerance = 10E-12;
|
||||||
|
|
||||||
protected double[] testArray =
|
protected double[] testArray =
|
||||||
{
|
{12.5, 12, 11.8, 14.2, 14.9, 14.5, 21, 8.2, 10.3, 11.3,
|
||||||
12.5,
|
14.1, 9.9, 12.2, 12, 12.1, 11, 19.8, 11, 10, 8.8,
|
||||||
12,
|
9, 12.3 };
|
||||||
11.8,
|
|
||||||
14.2,
|
|
||||||
14.9,
|
|
||||||
14.5,
|
|
||||||
21,
|
|
||||||
8.2,
|
|
||||||
10.3,
|
|
||||||
11.3,
|
|
||||||
14.1,
|
|
||||||
9.9,
|
|
||||||
12.2,
|
|
||||||
12,
|
|
||||||
12.1,
|
|
||||||
11,
|
|
||||||
19.8,
|
|
||||||
11,
|
|
||||||
10,
|
|
||||||
8.8,
|
|
||||||
9,
|
|
||||||
12.3 };
|
|
||||||
|
|
||||||
public UnivariateStatisticAbstractTest(String name) {
|
public UnivariateStatisticAbstractTest(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
|
|
@ -19,8 +19,8 @@ import org.apache.commons.math.stat.univariate.StorelessUnivariateStatisticAbstr
|
||||||
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
|
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test cases for the {@link UnivariateStatistic} class.
|
* Test cases for the {@link FirstMoment} class.
|
||||||
* @version $Revision: 1.2 $ $Date: 2004/06/17 21:37:05 $
|
* @version $Revision: 1.3 $ $Date: 2004/06/27 19:33:38 $
|
||||||
*/
|
*/
|
||||||
public class FirstMomentTest extends StorelessUnivariateStatisticAbstractTest{
|
public class FirstMomentTest extends StorelessUnivariateStatisticAbstractTest{
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2003-2004 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.commons.math.stat.univariate.moment;
|
||||||
|
|
||||||
|
import org.apache.commons.math.stat.univariate.StorelessUnivariateStatisticAbstractTest;
|
||||||
|
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test cases for the {@link FourthMoment} class.
|
||||||
|
* @version $Revision: 1.1 $ $Date: 2004/06/27 19:33:38 $
|
||||||
|
*/
|
||||||
|
public class FourthMomentTest extends StorelessUnivariateStatisticAbstractTest{
|
||||||
|
|
||||||
|
/** descriptive statistic. */
|
||||||
|
protected FourthMoment stat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
public FourthMomentTest(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest#getUnivariateStatistic()
|
||||||
|
*/
|
||||||
|
public UnivariateStatistic getUnivariateStatistic() {
|
||||||
|
return new FourthMoment();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest#expectedValue()
|
||||||
|
*/
|
||||||
|
public double expectedValue() {
|
||||||
|
return this.fourthMoment;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2003-2004 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.commons.math.stat.univariate.moment;
|
||||||
|
|
||||||
|
import org.apache.commons.math.stat.univariate.StorelessUnivariateStatisticAbstractTest;
|
||||||
|
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test cases for the {@link SecondMoment} class.
|
||||||
|
* @version $Revision: 1.1 $ $Date: 2004/06/27 19:33:38 $
|
||||||
|
*/
|
||||||
|
public class SecondMomentTest extends StorelessUnivariateStatisticAbstractTest {
|
||||||
|
|
||||||
|
/** descriptive statistic. */
|
||||||
|
protected SecondMoment stat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
public SecondMomentTest(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest#getUnivariateStatistic()
|
||||||
|
*/
|
||||||
|
public UnivariateStatistic getUnivariateStatistic() {
|
||||||
|
return new SecondMoment();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest#expectedValue()
|
||||||
|
*/
|
||||||
|
public double expectedValue() {
|
||||||
|
return this.secondMoment;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2003-2004 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.commons.math.stat.univariate.moment;
|
||||||
|
|
||||||
|
import org.apache.commons.math.stat.univariate.StorelessUnivariateStatisticAbstractTest;
|
||||||
|
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test cases for the {@link ThirdMoment} class.
|
||||||
|
* @version $Revision: 1.1 $ $Date: 2004/06/27 19:33:38 $
|
||||||
|
*/
|
||||||
|
public class ThirdMomentTest extends StorelessUnivariateStatisticAbstractTest{
|
||||||
|
|
||||||
|
/** descriptive statistic. */
|
||||||
|
protected ThirdMoment stat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
public ThirdMomentTest(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest#getUnivariateStatistic()
|
||||||
|
*/
|
||||||
|
public UnivariateStatistic getUnivariateStatistic() {
|
||||||
|
return new ThirdMoment();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest#expectedValue()
|
||||||
|
*/
|
||||||
|
public double expectedValue() {
|
||||||
|
return this.thirdMoment;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue