[MATH-1037] Fix GeometricDistributionTest. Thanks to Aleksei Dievskii for the report.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1531413 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Neidhart 2013-10-11 20:47:20 +00:00
parent df5fcca949
commit dcaca39d00
3 changed files with 12 additions and 4 deletions

View File

@ -51,6 +51,10 @@ If the output is not quite correct, check for invisible trailing spaces!
</properties>
<body>
<release version="x.y" date="TBD" description="TBD">
<action dev="tn" type="fix" issue="MATH-1037" due-to="Aleksei Dievskii">
Fix a typo in the "GeometricDistributionTest" and ensure that a meaningful
tolerance value is used when comparing test results with expected values.
</action>
<action dev="psteitz" type="add" issue="MATH-1034" due-to="Thorsten Schaefer">
Added exact binomial test implementation.
</action>

View File

@ -26,6 +26,10 @@ import org.junit.Test;
*/
public class GeometricDistributionTest extends IntegerDistributionAbstractTest {
public GeometricDistributionTest() {
setTolerance(1e-7);
}
// -------------- Implementations for abstract methods --------------------
/** Creates the default discrete distribution instance to use in tests. */
@ -39,7 +43,7 @@ public class GeometricDistributionTest extends IntegerDistributionAbstractTest {
public int[] makeDensityTestPoints() {
return new int[] { -1, 0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
29, 20, 21, 22, 23, 24, 25, 26, 27, 28 };
19, 20, 21, 22, 23, 24, 25, 26, 27, 28 };
}
/** Creates the default probability density test expected values */

View File

@ -135,7 +135,7 @@ public abstract class IntegerDistributionAbstractTest {
for (int i = 0; i < densityTestPoints.length; i++) {
Assert.assertEquals("Incorrect density value returned for " + densityTestPoints[i],
densityTestValues[i],
distribution.probability(densityTestPoints[i]), tolerance);
distribution.probability(densityTestPoints[i]), getTolerance());
}
}
@ -147,7 +147,7 @@ public abstract class IntegerDistributionAbstractTest {
for (int i = 0; i < cumulativeTestPoints.length; i++) {
Assert.assertEquals("Incorrect cumulative probability value returned for " + cumulativeTestPoints[i],
cumulativeTestValues[i],
distribution.cumulativeProbability(cumulativeTestPoints[i]), tolerance);
distribution.cumulativeProbability(cumulativeTestPoints[i]), getTolerance());
}
}
@ -199,7 +199,7 @@ public abstract class IntegerDistributionAbstractTest {
Assert.assertEquals("Cumulative probability mmust be 0 below support lower bound.",
0.0, distribution.cumulativeProbability(lower - 1), 0.0);
Assert.assertEquals("Cumulative probability of support lower bound must be equal to probability mass at this point.",
distribution.probability(lower), distribution.cumulativeProbability(lower), tolerance);
distribution.probability(lower), distribution.cumulativeProbability(lower), getTolerance());
Assert.assertEquals("Inverse cumulative probability of 0 must be equal to support lower bound.",
lower, distribution.inverseCumulativeProbability(0.0));