commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject [2/5] git commit: Corrected variance (Thanks Thomas) and added tests for inverseCumulativeProbability
Date Wed, 15 Oct 2014 07:14:31 GMT
Corrected variance (Thanks Thomas) and added tests for inverseCumulativeProbability


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/0dec6e76
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/0dec6e76
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/0dec6e76

Branch: refs/heads/master
Commit: 0dec6e76fb544fa3e8bf5fd17f16314735971dd7
Parents: 4cb944e
Author: Ole <ole.ersoy@gmail.com>
Authored: Fri Oct 10 17:24:57 2014 -0500
Committer: Ole <ole.ersoy@gmail.com>
Committed: Fri Oct 10 17:24:57 2014 -0500

----------------------------------------------------------------------
 .../AbstractIntegerDistributionTest.java        | 21 +++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/0dec6e76/src/test/java/org/apache/commons/math3/distribution/AbstractIntegerDistributionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/distribution/AbstractIntegerDistributionTest.java
b/src/test/java/org/apache/commons/math3/distribution/AbstractIntegerDistributionTest.java
index 97ea5a0..d6f668b 100644
--- a/src/test/java/org/apache/commons/math3/distribution/AbstractIntegerDistributionTest.java
+++ b/src/test/java/org/apache/commons/math3/distribution/AbstractIntegerDistributionTest.java
@@ -28,6 +28,25 @@ public class AbstractIntegerDistributionTest {
     protected final double p = diceDistribution.probability(1);
 
     @Test
+    public void testInverseCumulativeProbabilityMethod()
+    {
+    	double precision = 0.000000000000001;
+    	Assert.assertEquals(1, diceDistribution.inverseCumulativeProbability(0));
+    	Assert.assertEquals(1, diceDistribution.inverseCumulativeProbability((1d-Double.MIN_VALUE)/6d));
+    	Assert.assertEquals(2, diceDistribution.inverseCumulativeProbability((1d+precision)/6d));
+    	Assert.assertEquals(2, diceDistribution.inverseCumulativeProbability((2d-Double.MIN_VALUE)/6d));
+    	Assert.assertEquals(3, diceDistribution.inverseCumulativeProbability((2d+precision)/6d));
+    	Assert.assertEquals(3, diceDistribution.inverseCumulativeProbability((3d-Double.MIN_VALUE)/6d));
+    	Assert.assertEquals(4, diceDistribution.inverseCumulativeProbability((3d+precision)/6d));
+    	Assert.assertEquals(4, diceDistribution.inverseCumulativeProbability((4d-Double.MIN_VALUE)/6d));
+    	Assert.assertEquals(5, diceDistribution.inverseCumulativeProbability((4d+precision)/6d));
+    	Assert.assertEquals(5, diceDistribution.inverseCumulativeProbability((5d-precision)/6d));//Can't
use Double.MIN
+    	Assert.assertEquals(6, diceDistribution.inverseCumulativeProbability((5d+precision)/6d));
+    	Assert.assertEquals(6, diceDistribution.inverseCumulativeProbability((6d-precision)/6d));//Can't
use Double.MIN
+    	Assert.assertEquals(6, diceDistribution.inverseCumulativeProbability((6d)/6d));
+    }
+
+    @Test
     public void testCumulativeProbabilitiesSingleArguments() {
         for (int i = 1; i < 7; i++) {
             Assert.assertEquals(p * i,
@@ -90,7 +109,7 @@ public class AbstractIntegerDistributionTest {
         }
 
         public double getNumericalVariance() {
-            return 12.5 - 3.5 * 3.5;  // E(X^2) - E(X)^2
+            return 70/24;  // E(X^2) - E(X)^2
         }
 
         public int getSupportLowerBound() {


Mime
View raw message