This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-statistics.git
The following commit(s) were added to refs/heads/master by this push:
new 28b9077e STATISTICS-104: Correct test expected result and tolerances
28b9077e is described below
commit 28b9077e4b447832d0d9d1a7574847fb4a2f4818
Author: Alex Herbert <[email protected]>
AuthorDate: Fri Dec 4 16:57:19 2026 +0000
STATISTICS-104: Correct test expected result and tolerances
The exact PMF used p = 1 - 0.7 instead of the binary p = 0.3. The
expected value has been corrected. It moves the expected value
by 9 ULP. The tolerances for the two JDK dependent results
change from 8 and 10 to 17 and 1. One result is close to
the expected result and matches the R reference value, the other
result has ~3.3e-15 relative error to the expected value.
---
.../distribution/BinomialDistributionTest.java | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git
a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BinomialDistributionTest.java
b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BinomialDistributionTest.java
index 76508ae7..fed38442 100644
---
a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BinomialDistributionTest.java
+++
b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BinomialDistributionTest.java
@@ -385,15 +385,14 @@ class BinomialDistributionTest extends
BaseDiscreteDistributionTest {
// The saddle-point expansion uses log and the PMF uses exp.
// log(1.377810000000004E-4) and log(1.377809999999999E-4) are 2 ULP
apart.
final double pj = dist.probability(9);
- // The exact result sits in between the two values above.
- // new BigDecimal(1 - 0.7).pow(9).multiply(new
BigDecimal(0.7)).multiply(new BigDecimal(10)).doubleValue()
- final double expected = 1.3778100000000018E-4;
- TestUtils.assertEquals(expected, pj, DoubleTolerances.ulps(10));
- // The two PMF values are +8 or -10 to the exact result.
- // If the Java version computes the upper one then it is 18 ULP
different from R
- // but closer to the exact result.
+ // The exact result is:
+ // new BigDecimal(0.3).pow(9).multiply(new BigDecimal(1 -
0.3)).multiply(new BigDecimal(10)).doubleValue()
+ final double expected = 1.3778099999999993E-4;
+ TestUtils.assertEquals(expected, pj, DoubleTolerances.ulps(17));
+ // The two PMF values are -1 or +17 ULP to the exact result rounded to
double.
+ // If the Java version computes the upper one then it is 18 ULP
different from R.
// The test case has been updated to use 2^-48 relative eps (5 bits) ~
4e-15.
- TestUtils.assertEquals(expected, 1.377810000000004E-4,
DoubleTolerances.ulps(8));
- TestUtils.assertEquals(expected, 1.377809999999999E-4,
DoubleTolerances.ulps(10));
+ TestUtils.assertEquals(expected, 1.377810000000004E-4,
DoubleTolerances.ulps(17));
+ TestUtils.assertEquals(expected, 1.377809999999999E-4,
DoubleTolerances.ulps(1));
}
}