commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r1173313 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java
Date Tue, 20 Sep 2011 19:21:00 GMT
Author: psteitz
Date: Tue Sep 20 19:20:59 2011
New Revision: 1173313

URL: http://svn.apache.org/viewvc?rev=1173313&view=rev
Log:
Added test for consistency of cumulativeProbability(double,double) and cumulativeProbability(double).
 Contributed by Christian Winter.

Modified:
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java?rev=1173313&r1=1173312&r2=1173313&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java
Tue Sep 20 19:20:59 2011
@@ -20,6 +20,7 @@ package org.apache.commons.math.distribu
 import org.apache.commons.math.TestUtils;
 import org.apache.commons.math.util.FastMath;
 import org.apache.commons.math.exception.MathIllegalArgumentException;
+import org.apache.commons.math.exception.NumberIsTooLargeException;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -144,12 +145,30 @@ public abstract class ContinuousDistribu
      * using current test instance data
      */
     protected void verifyCumulativeProbabilities() throws Exception {
+        // verify cumulativeProbability(double)
         for (int i = 0; i < cumulativeTestPoints.length; i++) {
             TestUtils.assertEquals("Incorrect cumulative probability value returned for "
                 + cumulativeTestPoints[i], cumulativeTestValues[i],
                 distribution.cumulativeProbability(cumulativeTestPoints[i]),
                 getTolerance());
         }
+        // verify cumulativeProbability(double, double)
+        for (int i = 0; i < cumulativeTestPoints.length; i++) {
+            for (int j = 0; j < cumulativeTestPoints.length; j++) {
+                if (cumulativeTestPoints[i] <= cumulativeTestPoints[j]) {
+                    TestUtils.assertEquals(cumulativeTestValues[j] - cumulativeTestValues[i],
+                        distribution.cumulativeProbability(cumulativeTestPoints[i], cumulativeTestPoints[j]),
+                        getTolerance());
+                } else {
+                    try {
+                        distribution.cumulativeProbability(cumulativeTestPoints[i], cumulativeTestPoints[j]);
+                    } catch (NumberIsTooLargeException e) {
+                        continue;
+                    }
+                    Assert.fail("distribution.cumulativeProbability(double, double) should
have thrown an exception that second argument is too large");
+                }
+            }
+        }
     }
 
     /**



Mime
View raw message