Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
bd3a6ecaa7
3
pom.xml
3
pom.xml
|
@ -203,6 +203,9 @@
|
|||
<contributor>
|
||||
<name>Ted Dunning</name>
|
||||
</contributor>
|
||||
<contributor>
|
||||
<name>Ole Ersoy</name>
|
||||
</contributor>
|
||||
<contributor>
|
||||
<name>Ajo Fod</name>
|
||||
</contributor>
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue