You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2016/01/12 16:57:48 UTC
[math] Dropped useless tests;
added KS test for uniformity of nextDouble. JIRA: MATH-1317.
Repository: commons-math
Updated Branches:
refs/heads/master d749b2e76 -> 4742149a8
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/4742149a
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/4742149a
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/4742149a
Branch: refs/heads/master
Commit: 4742149a8d979f3d97d846f90774460f41184104
Parents: d749b2e
Author: Phil Steitz <ph...@gmail.com>
Authored: Tue Jan 12 08:57:35 2016 -0700
Committer: Phil Steitz <ph...@gmail.com>
Committed: Tue Jan 12 08:57:35 2016 -0700
----------------------------------------------------------------------
.../random/RandomGeneratorAbstractTest.java | 34 +++++++-------------
1 file changed, 11 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/4742149a/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 816e9ab..7c0384e 100644
--- a/src/test/java/org/apache/commons/math4/random/RandomGeneratorAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/random/RandomGeneratorAbstractTest.java
@@ -19,16 +19,16 @@ package org.apache.commons.math4.random;
import java.util.Arrays;
import org.apache.commons.math4.TestUtils;
+import org.apache.commons.math4.distribution.RealDistribution;
+import org.apache.commons.math4.distribution.UniformRealDistribution;
import org.apache.commons.math4.exception.MathIllegalArgumentException;
-import org.apache.commons.math4.random.RandomDataGenerator;
-import org.apache.commons.math4.random.RandomGenerator;
import org.apache.commons.math4.stat.Frequency;
-import org.apache.commons.math4.stat.descriptive.SummaryStatistics;
+import org.apache.commons.math4.stat.inference.KolmogorovSmirnovTest;
import org.apache.commons.math4.util.FastMath;
import org.junit.Assert;
import org.junit.Before;
-import org.junit.Test;
import org.junit.Ignore;
+import org.junit.Test;
/**
* Base class for RandomGenerator tests.
@@ -247,28 +247,16 @@ 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());
+ public void testNextDouble() {
+ final double[] sample = new double[1000];
+ for (int i = 0; i < sample.length; i++) {
+ sample[i] = generator.nextDouble();
}
- Assert.assertEquals(0.5, sample.getMean(), 0.01);
- 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
- public void testFloatDirect() {
- SummaryStatistics sample = new SummaryStatistics();
- final int N = 10000;
- for (int i = 0; i < N; ++i) {
- sample.addValue(generator.nextFloat());
- }
- Assert.assertEquals(0.5, sample.getMean(), 0.01);
- Assert.assertEquals(1.0 / (2.0 * FastMath.sqrt(3.0)),
- sample.getStandardDeviation(), 0.01);
- }
@Test(expected=MathIllegalArgumentException.class)
public void testNextIntPrecondition1() {