commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [math] MATH-1313
Date Mon, 11 Jan 2016 11:06:55 GMT
Repository: commons-math
Updated Branches:
  refs/heads/master e76bf903a -> 2df0a3be6


MATH-1313

Wrong tolerance in unit tests.

The tests themselves are weak and should be replaced (see also MATH-1317).


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/2df0a3be
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/2df0a3be
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/2df0a3be

Branch: refs/heads/master
Commit: 2df0a3be66f6fa1067d976d7a05500beff7eda53
Parents: e76bf90
Author: Gilles <erans@apache.org>
Authored: Mon Jan 11 12:02:09 2016 +0100
Committer: Gilles <erans@apache.org>
Committed: Mon Jan 11 12:02:09 2016 +0100

----------------------------------------------------------------------
 .../commons/math4/random/RandomGeneratorAbstractTest.java    | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/2df0a3be/src/test/java/org/apache/commons/math4/random/RandomGeneratorAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/RandomGeneratorAbstractTest.java
b/src/test/java/org/apache/commons/math4/random/RandomGeneratorAbstractTest.java
index 8237d9a..816e9ab 100644
--- a/src/test/java/org/apache/commons/math4/random/RandomGeneratorAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/random/RandomGeneratorAbstractTest.java
@@ -253,8 +253,7 @@ public abstract class RandomGeneratorAbstractTest extends RandomDataGeneratorTes
         for (int i = 0; i < N; ++i) {
             sample.addValue(generator.nextDouble());
         }
-        Assert.assertEquals("Note: This test will fail randomly about 1 in 100 times.",
-                0.5, sample.getMean(), FastMath.sqrt(N/12.0) * 2.576);
+        Assert.assertEquals(0.5, sample.getMean(), 0.01);
         Assert.assertEquals(1.0 / (2.0 * FastMath.sqrt(3.0)),
                      sample.getStandardDeviation(), 0.01);
     }
@@ -262,12 +261,11 @@ public abstract class RandomGeneratorAbstractTest extends RandomDataGeneratorTes
     @Test
     public void testFloatDirect() {
         SummaryStatistics sample = new SummaryStatistics();
-        final int N = 1000;
+        final int N = 10000;
         for (int i = 0; i < N; ++i) {
             sample.addValue(generator.nextFloat());
         }
-        Assert.assertEquals("Note: This test will fail randomly about 1 in 100 times.",
-                0.5, sample.getMean(), FastMath.sqrt(N/12.0) * 2.576);
+        Assert.assertEquals(0.5, sample.getMean(), 0.01);
         Assert.assertEquals(1.0 / (2.0 * FastMath.sqrt(3.0)),
                      sample.getStandardDeviation(), 0.01);
     }


Mime
View raw message