Repository: commons-math
Updated Branches:
  refs/heads/MATH_3_X 607511fd6 -> d0364b7d3


Dropped useless tests; added KS test for uniformity of nextDouble.  JIRA: 
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/d0364b7d
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/d0364b7d
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/d0364b7d

Branch: refs/heads/MATH_3_X
Commit: d0364b7d385283747625c197fbd3a4d36da19f39
Parents: 607511f
Author: Phil Steitz <phil.ste...@gmail.com>
Authored: Tue Jan 12 12:05:51 2016 -0700
Committer: Phil Steitz <phil.ste...@gmail.com>
Committed: Tue Jan 12 12:05:51 2016 -0700

----------------------------------------------------------------------
 .../random/RandomGeneratorAbstractTest.java     | 36 ++++++--------------
 1 file changed, 11 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/d0364b7d/src/test/java/org/apache/commons/math3/random/RandomGeneratorAbstractTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/math3/random/RandomGeneratorAbstractTest.java
 
b/src/test/java/org/apache/commons/math3/random/RandomGeneratorAbstractTest.java
index 0c492b1..4d14dde 100644
--- 
a/src/test/java/org/apache/commons/math3/random/RandomGeneratorAbstractTest.java
+++ 
b/src/test/java/org/apache/commons/math3/random/RandomGeneratorAbstractTest.java
@@ -19,11 +19,12 @@ package org.apache.commons.math3.random;
 import java.util.Arrays;
 
 import org.apache.commons.math3.TestUtils;
+import org.apache.commons.math3.distribution.RealDistribution;
+import org.apache.commons.math3.distribution.UniformRealDistribution;
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
 import org.apache.commons.math3.stat.Frequency;
-import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
+import org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest;
 import org.apache.commons.math3.util.FastMath;
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -260,29 +261,14 @@ public abstract class RandomGeneratorAbstractTest extends 
RandomDataGeneratorTes
     }
 
     @Test
-    public void testDoubleDirect() {
-        SummaryStatistics sample = new SummaryStatistics();
-        final int N = 10000;
-        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(1.0 / (2.0 * FastMath.sqrt(3.0)),
-                     sample.getStandardDeviation(), 0.01);
-    }
-
-    @Test
-    public void testFloatDirect() {
-        SummaryStatistics sample = new SummaryStatistics();
-        final int N = 1000;
-        for (int i = 0; i < N; ++i) {
-            sample.addValue(generator.nextFloat());
+    public void testNextDouble() {
+        final double[] sample = new double[10000];
+        for (int i = 0; i < sample.length; i++) {
+            sample[i] = 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(1.0 / (2.0 * FastMath.sqrt(3.0)),
-                     sample.getStandardDeviation(), 0.01);
+        final RealDistribution uniformDistribution = new 
UniformRealDistribution(0,1);
+        final KolmogorovSmirnovTest ks = new KolmogorovSmirnovTest();
+        Assert.assertFalse(ks.kolmogorovSmirnovTest(uniformDistribution, 
sample, .01));
     }
 
     @Test(expected=MathIllegalArgumentException.class)

Reply via email to