You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2019/09/25 10:43:00 UTC
[commons-rng] branch master updated: Copy updated providers common
tests from core module to simple module.
This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git
The following commit(s) were added to refs/heads/master by this push:
new 9d0695e Copy updated providers common tests from core module to simple module.
9d0695e is described below
commit 9d0695e75f3068a47477825fd1357ec9f0521967
Author: aherbert <ah...@apache.org>
AuthorDate: Wed Sep 25 11:42:56 2019 +0100
Copy updated providers common tests from core module to simple module.
---
.../rng/core/ProvidersCommonParametricTest.java | 4 ++--
.../rng/simple/ProvidersCommonParametricTest.java | 18 ++++++++++++++----
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/commons-rng-core/src/test/java/org/apache/commons/rng/core/ProvidersCommonParametricTest.java b/commons-rng-core/src/test/java/org/apache/commons/rng/core/ProvidersCommonParametricTest.java
index 07489dd..98e0dc0 100644
--- a/commons-rng-core/src/test/java/org/apache/commons/rng/core/ProvidersCommonParametricTest.java
+++ b/commons-rng-core/src/test/java/org/apache/commons/rng/core/ProvidersCommonParametricTest.java
@@ -470,8 +470,8 @@ public class ProvidersCommonParametricTest {
* {@code nextMethod}.
* It performs a chi-square test of homogeneity of the observed
* distribution with the expected uniform distribution.
- * Tests are performed at the 1% level and an average failure rate
- * higher than 2% causes the test case to fail.
+ * Repeat tests are performed at the 1% level and the total number of failed
+ * tests is tested at the 0.5% significance level.
*
* @param max Upper bound.
* @param nextMethod method to call.
diff --git a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/ProvidersCommonParametricTest.java b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/ProvidersCommonParametricTest.java
index 882f0b0..c09e2e5 100644
--- a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/ProvidersCommonParametricTest.java
+++ b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/ProvidersCommonParametricTest.java
@@ -255,7 +255,7 @@ public class ProvidersCommonParametricTest {
list.add(generator.nextFloat());
list.add(generator.nextDouble());
list.add(generator.nextDouble());
- list.add(generator.nextDouble());
+ list.add(generator.nextBoolean() ? 1 : 0);
}
return list;
@@ -286,8 +286,8 @@ public class ProvidersCommonParametricTest {
* {@code nextMethod}.
* It performs a chi-square test of homogeneity of the observed
* distribution with the expected uniform distribution.
- * Tests are performed at the 1% level and an average failure rate
- * higher than 2% causes the test case to fail.
+ * Repeat tests are performed at the 1% level and the total number of failed
+ * tests is tested at the 0.5% significance level.
*
* @param max Upper bound.
* @param nextMethod method to call.
@@ -308,6 +308,8 @@ public class ProvidersCommonParametricTest {
for (int k = 0; k < numBins; k++) {
binUpperBounds[k] = (long) ((k + 1) * step);
}
+ // Rounding error occurs on the long value of 2305843009213693951L
+ binUpperBounds[numBins - 1] = n;
// Run the tests.
int numFailures = 0;
@@ -357,7 +359,15 @@ public class ProvidersCommonParametricTest {
throw new RuntimeException("Unexpected", e);
}
- if ((double) numFailures / (double) numTests > 0.02) {
+ // The expected number of failed tests can be modelled as a Binomial distribution
+ // B(n, p) with n=500, p=0.01 (500 tests with a 1% significance level).
+ // The cumulative probability of the number of failed tests (X) is:
+ // x P(X>x)
+ // 10 0.0132
+ // 11 0.00521
+ // 12 0.00190
+
+ if (numFailures > 11) { // Test will fail with 0.5% probability
Assert.fail(generator + ": Too many failures for n = " + n +
" (" + numFailures + " out of " + numTests + " tests failed)");
}