Purified tests introduced in MATH-385 such that NaNs and infinites are handled properly

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1053472 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mikkel Meyer Andersen 2010-12-28 22:19:34 +00:00
parent 38155d7ef3
commit 392f47dfed
3 changed files with 11 additions and 12 deletions

View File

@ -109,15 +109,14 @@ public class CauchyDistributionTest extends ContinuousDistributionAbstractTest
}
public void testMomonts() {
final double tol = 1e-9;
CauchyDistribution dist;
dist = new CauchyDistributionImpl(10.2, 0.15);
assertEquals(dist.getNumericalMean(), Double.NaN, tol);
assertEquals(dist.getNumericalVariance(), Double.NaN, tol);
dist = new CauchyDistributionImpl(10.2, 0.15);
assertTrue(Double.isNaN(dist.getNumericalMean()));
assertTrue(Double.isNaN(dist.getNumericalVariance()));
dist = new CauchyDistributionImpl(23.12, 2.12);
assertEquals(dist.getNumericalMean(), Double.NaN, tol);
assertEquals(dist.getNumericalVariance(), Double.NaN, tol);
assertTrue(Double.isNaN(dist.getNumericalMean()));
assertTrue(Double.isNaN(dist.getNumericalVariance()));
}
}

View File

@ -130,12 +130,12 @@ public class FDistributionTest extends ContinuousDistributionAbstractTest {
FDistribution dist;
dist = new FDistributionImpl(1, 2);
assertEquals(dist.getNumericalMean(), Double.NaN, tol);
assertEquals(dist.getNumericalVariance(), Double.NaN, tol);
assertTrue(Double.isNaN(dist.getNumericalMean()));
assertTrue(Double.isNaN(dist.getNumericalVariance()));
dist = new FDistributionImpl(1, 3);
assertEquals(dist.getNumericalMean(), 3d / (3d - 2d), tol);
assertEquals(dist.getNumericalVariance(), Double.NaN, tol);
assertTrue(Double.isNaN(dist.getNumericalVariance()));
dist = new FDistributionImpl(1, 5);
assertEquals(dist.getNumericalMean(), 5d / (5d - 2d), tol);

View File

@ -124,12 +124,12 @@ public class TDistributionTest extends ContinuousDistributionAbstractTest {
TDistribution dist;
dist = new TDistributionImpl(1);
assertEquals(dist.getNumericalMean(), Double.NaN, tol);
assertEquals(dist.getNumericalVariance(), Double.NaN, tol);
assertTrue(Double.isNaN(dist.getNumericalMean()));
assertTrue(Double.isNaN(dist.getNumericalVariance()));
dist = new TDistributionImpl(1.5);
assertEquals(dist.getNumericalMean(), 0, tol);
assertEquals(dist.getNumericalVariance(), Double.POSITIVE_INFINITY, tol);
assertTrue(Double.isInfinite(dist.getNumericalVariance()));
dist = new TDistributionImpl(5);
assertEquals(dist.getNumericalMean(), 0, tol);