diff --git a/pom.xml b/pom.xml index 3a62e60a9..843013111 100644 --- a/pom.xml +++ b/pom.xml @@ -203,6 +203,9 @@ Ted Dunning + + Ole Ersoy + Ajo Fod diff --git a/src/main/java/org/apache/commons/math3/exception/MathIllegalStateException.java b/src/main/java/org/apache/commons/math3/exception/MathIllegalStateException.java index 22f881214..2bb4a7100 100644 --- a/src/main/java/org/apache/commons/math3/exception/MathIllegalStateException.java +++ b/src/main/java/org/apache/commons/math3/exception/MathIllegalStateException.java @@ -22,8 +22,9 @@ import org.apache.commons.math3.exception.util.ExceptionContext; import org.apache.commons.math3.exception.util.ExceptionContextProvider; /** - * Base class for all exceptions that signal a mismatch between the - * current state and the user's expectations. + * Base class for all exceptions that signal that the process + * throwing the exception is in a state that does not comply with + * the set of states the it is designed to be in. * * @since 2.2 */ 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 97ea5a0bb..d6f668bb2 100644 --- a/src/test/java/org/apache/commons/math3/distribution/AbstractIntegerDistributionTest.java +++ b/src/test/java/org/apache/commons/math3/distribution/AbstractIntegerDistributionTest.java @@ -27,6 +27,25 @@ public class AbstractIntegerDistributionTest { protected final DiceDistribution diceDistribution = new DiceDistribution(); 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++) { @@ -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() {