Adding incremental tests for storeless univariates as evaluations are now based on the implementations that were previously provided by StatUtils.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@140968 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark R. Diggory 2003-07-07 02:12:47 +00:00
parent 346a5756eb
commit b6871d607e
13 changed files with 116 additions and 12 deletions

View File

@ -0,0 +1,93 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.commons.math.stat.univariate;
import junit.framework.TestCase;
/**
* Test cases for the {@link UnivariateStatistic} class.
*
* @author Mark Diggory
*/
public abstract class StorelessUnivariateStatisticAbstractTest
extends UnivariateStatisticAbstractTest {
public StorelessUnivariateStatisticAbstractTest(String name) {
super(name);
}
public abstract UnivariateStatistic getUnivariateStatistic();
public abstract double expectedValue();
public void testIncrementation() throws Exception {
StorelessUnivariateStatistic statistic =
(StorelessUnivariateStatistic) getUnivariateStatistic();
statistic.clear();
for (int i = 0; i < testArray.length; i++) {
statistic.increment(testArray[i]);
}
assertEquals(expectedValue(), statistic.getValue(), getTolerance());
statistic.clear();
assertTrue(Double.isNaN(statistic.getValue()));
}
}

View File

@ -124,5 +124,5 @@ public abstract class UnivariateStatisticAbstractTest extends TestCase {
getUnivariateStatistic().evaluate(testArray),
getTolerance());
}
}

View File

@ -56,6 +56,7 @@ package org.apache.commons.math.stat.univariate.moment;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.math.stat.univariate.StorelessUnivariateStatisticAbstractTest;
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
@ -64,7 +65,7 @@ import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
*
* @author Mark Diggory
*/
public class KurtosisTest extends UnivariateStatisticAbstractTest{
public class KurtosisTest extends StorelessUnivariateStatisticAbstractTest{
protected Kurtosis stat;

View File

@ -56,6 +56,7 @@ package org.apache.commons.math.stat.univariate.moment;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.math.stat.univariate.StorelessUnivariateStatisticAbstractTest;
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
@ -64,7 +65,7 @@ import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
*
* @author Mark Diggory
*/
public class MeanTest extends UnivariateStatisticAbstractTest{
public class MeanTest extends StorelessUnivariateStatisticAbstractTest{
protected Mean stat;

View File

@ -56,6 +56,7 @@ package org.apache.commons.math.stat.univariate.moment;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.math.stat.univariate.StorelessUnivariateStatisticAbstractTest;
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
@ -64,7 +65,7 @@ import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
*
* @author Mark Diggory
*/
public class SkewnessTest extends UnivariateStatisticAbstractTest{
public class SkewnessTest extends StorelessUnivariateStatisticAbstractTest{
protected Skewness stat;

View File

@ -56,6 +56,7 @@ package org.apache.commons.math.stat.univariate.moment;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.math.stat.univariate.StorelessUnivariateStatisticAbstractTest;
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
@ -64,7 +65,7 @@ import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
*
* @author Mark Diggory
*/
public class StandardDeviationTest extends UnivariateStatisticAbstractTest{
public class StandardDeviationTest extends StorelessUnivariateStatisticAbstractTest{
protected StandardDeviation stat;

View File

@ -56,6 +56,7 @@ package org.apache.commons.math.stat.univariate.moment;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.math.stat.univariate.StorelessUnivariateStatisticAbstractTest;
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
@ -64,7 +65,7 @@ import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
*
* @author Mark Diggory
*/
public class VarianceTest extends UnivariateStatisticAbstractTest{
public class VarianceTest extends StorelessUnivariateStatisticAbstractTest{
protected Variance stat;

View File

@ -56,6 +56,7 @@ package org.apache.commons.math.stat.univariate.rank;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.math.stat.univariate.StorelessUnivariateStatisticAbstractTest;
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
@ -64,7 +65,7 @@ import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
*
* @author Mark Diggory
*/
public class MaxTest extends UnivariateStatisticAbstractTest{
public class MaxTest extends StorelessUnivariateStatisticAbstractTest{
protected Max stat;

View File

@ -56,6 +56,7 @@ package org.apache.commons.math.stat.univariate.rank;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.math.stat.univariate.StorelessUnivariateStatisticAbstractTest;
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
@ -64,7 +65,7 @@ import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
*
* @author Mark Diggory
*/
public class MinTest extends UnivariateStatisticAbstractTest{
public class MinTest extends StorelessUnivariateStatisticAbstractTest{
protected Min stat;

View File

@ -56,6 +56,7 @@ package org.apache.commons.math.stat.univariate.summary;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.math.stat.univariate.StorelessUnivariateStatisticAbstractTest;
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
@ -64,7 +65,7 @@ import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
*
* @author Mark Diggory
*/
public class ProductTest extends UnivariateStatisticAbstractTest{
public class ProductTest extends StorelessUnivariateStatisticAbstractTest{
protected Product stat;

View File

@ -56,6 +56,7 @@ package org.apache.commons.math.stat.univariate.summary;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.math.stat.univariate.StorelessUnivariateStatisticAbstractTest;
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
@ -64,7 +65,7 @@ import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
*
* @author Mark Diggory
*/
public class SumLogTest extends UnivariateStatisticAbstractTest{
public class SumLogTest extends StorelessUnivariateStatisticAbstractTest{
protected SumOfLogs stat;

View File

@ -56,6 +56,7 @@ package org.apache.commons.math.stat.univariate.summary;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.math.stat.univariate.StorelessUnivariateStatisticAbstractTest;
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
@ -64,7 +65,7 @@ import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
*
* @author Mark Diggory
*/
public class SumSqTest extends UnivariateStatisticAbstractTest{
public class SumSqTest extends StorelessUnivariateStatisticAbstractTest{
protected SumOfSquares stat;

View File

@ -56,6 +56,7 @@ package org.apache.commons.math.stat.univariate.summary;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.math.stat.univariate.StorelessUnivariateStatisticAbstractTest;
import org.apache.commons.math.stat.univariate.UnivariateStatistic;
import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
@ -64,7 +65,7 @@ import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
*
* @author Mark Diggory
*/
public class SumTest extends UnivariateStatisticAbstractTest{
public class SumTest extends StorelessUnivariateStatisticAbstractTest{
protected Sum stat;