Skip to content

Commit

Permalink
MATH-1313
Browse files Browse the repository at this point in the history
Wrong tolerance in unit tests.

The tests themselves are weak and should be replaced (see also MATH-1317).
  • Loading branch information
Gilles committed Jan 11, 2016
1 parent e76bf90 commit 2df0a3b
Showing 1 changed file with 3 additions and 5 deletions.
Expand Up @@ -253,21 +253,19 @@ public void testDoubleDirect() {
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);
}

@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);
}
Expand Down

0 comments on commit 2df0a3b

Please sign in to comment.