From c1062adc049f9f3659848902b6454c611146e9d1 Mon Sep 17 00:00:00 2001 From: Phil Steitz Date: Tue, 29 Jun 2004 06:11:22 +0000 Subject: [PATCH] Added small sample tests for 2nd+ order moments. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141349 13f79535-47bb-0310-9956-ffa450edef68 --- .../StorelessUnivariateStatisticAbstractTest.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/test/org/apache/commons/math/stat/univariate/StorelessUnivariateStatisticAbstractTest.java b/src/test/org/apache/commons/math/stat/univariate/StorelessUnivariateStatisticAbstractTest.java index ef45a1bb6..8b27dc276 100644 --- a/src/test/org/apache/commons/math/stat/univariate/StorelessUnivariateStatisticAbstractTest.java +++ b/src/test/org/apache/commons/math/stat/univariate/StorelessUnivariateStatisticAbstractTest.java @@ -16,10 +16,11 @@ package org.apache.commons.math.stat.univariate; import org.apache.commons.math.TestUtils; +import org.apache.commons.math.stat.univariate.moment.SecondMoment; /** - * Test cases for the {@link UnivariateStatistic} class. - * @version $Revision: 1.13 $ $Date: 2004/06/17 22:33:23 $ + * Test cases for {@link StorelessUnivariateStatistic} classes. + * @version $Revision: 1.14 $ $Date: 2004/06/29 06:11:22 $ */ public abstract class StorelessUnivariateStatisticAbstractTest extends UnivariateStatisticAbstractTest { @@ -125,5 +126,15 @@ public abstract class StorelessUnivariateStatisticAbstractTest emptyHash, statistic.hashCode()); } + + public void testMomentSmallSamples() { + UnivariateStatistic stat = getUnivariateStatistic(); + if (stat instanceof SecondMoment) { + SecondMoment moment = (SecondMoment) getUnivariateStatistic(); + assertTrue(Double.isNaN(moment.getResult())); + moment.increment(1d); + assertEquals(0d, moment.getResult(), 0); + } + } }