Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4F906200C78 for ; Thu, 4 May 2017 00:13:30 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4E319160BBA; Wed, 3 May 2017 22:13:30 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6E487160BB5 for ; Thu, 4 May 2017 00:13:29 +0200 (CEST) Received: (qmail 81947 invoked by uid 500); 3 May 2017 22:13:28 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 81938 invoked by uid 99); 3 May 2017 22:13:28 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 May 2017 22:13:28 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7C704E028C; Wed, 3 May 2017 22:13:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: erans@apache.org To: commits@commons.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [math] Depend on snapshot version of "Commons RNG". Date: Wed, 3 May 2017 22:13:28 +0000 (UTC) archived-at: Wed, 03 May 2017 22:13:30 -0000 Repository: commons-math Updated Branches: refs/heads/master dff1a0953 -> cc26f76ad Depend on snapshot version of "Commons RNG". Replace usage of "BoxMullerGaussianSampler" (to be deprecated in the next version of "Commons RNG"). Update unit tests that are overly sensitive to the sequence generated by the RNG. Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/cc26f76a Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/cc26f76a Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/cc26f76a Branch: refs/heads/master Commit: cc26f76ad1e02bc157066d1903aae9214ad34702 Parents: dff1a09 Author: Gilles Authored: Thu May 4 00:10:51 2017 +0200 Committer: Gilles Committed: Thu May 4 00:10:51 2017 +0200 ---------------------------------------------------------------------- pom.xml | 2 +- .../math4/distribution/LogNormalDistribution.java | 4 ++-- .../commons/math4/distribution/NormalDistribution.java | 6 ++++-- .../apache/commons/math4/filter/KalmanFilterTest.java | 2 +- .../leastsquares/LevenbergMarquardtOptimizerTest.java | 2 +- .../scalar/MultiStartMultivariateOptimizerTest.java | 12 +++++++----- .../random/UncorrelatedRandomVectorGeneratorTest.java | 4 ++-- 7 files changed, 18 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-math/blob/cc26f76a/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 5263413..86242b5 100644 --- a/pom.xml +++ b/pom.xml @@ -375,7 +375,7 @@ org.apache.commons commons-rng-sampling - 1.0 + 1.1-SNAPSHOT http://git-wip-us.apache.org/repos/asf/commons-math/blob/cc26f76a/src/main/java/org/apache/commons/math4/distribution/LogNormalDistribution.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/distribution/LogNormalDistribution.java b/src/main/java/org/apache/commons/math4/distribution/LogNormalDistribution.java index 575466d..67c1194 100644 --- a/src/main/java/org/apache/commons/math4/distribution/LogNormalDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/LogNormalDistribution.java @@ -24,7 +24,7 @@ import org.apache.commons.math4.special.Erf; import org.apache.commons.math4.util.FastMath; import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.sampling.distribution.ContinuousSampler; -import org.apache.commons.rng.sampling.distribution.BoxMullerLogNormalSampler; +import org.apache.commons.rng.sampling.distribution.MarsagliaLogNormalSampler; /** * Implementation of the log-normal (gaussian) distribution. @@ -295,7 +295,7 @@ public class LogNormalDistribution extends AbstractRealDistribution { public RealDistribution.Sampler createSampler(final UniformRandomProvider rng) { return new RealDistribution.Sampler() { private final ContinuousSampler sampler = - new BoxMullerLogNormalSampler(rng, scale, shape); + new MarsagliaLogNormalSampler(rng, scale, shape); /**{@inheritDoc} */ @Override http://git-wip-us.apache.org/repos/asf/commons-math/blob/cc26f76a/src/main/java/org/apache/commons/math4/distribution/NormalDistribution.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/distribution/NormalDistribution.java b/src/main/java/org/apache/commons/math4/distribution/NormalDistribution.java index 71eee15..3de0852 100644 --- a/src/main/java/org/apache/commons/math4/distribution/NormalDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/NormalDistribution.java @@ -25,7 +25,8 @@ import org.apache.commons.math4.special.Erf; import org.apache.commons.math4.util.FastMath; import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.sampling.distribution.ContinuousSampler; -import org.apache.commons.rng.sampling.distribution.BoxMullerGaussianSampler; +import org.apache.commons.rng.sampling.distribution.GaussianSampler; +import org.apache.commons.rng.sampling.distribution.MarsagliaNormalizedGaussianSampler; /** * Implementation of the normal (gaussian) distribution. @@ -242,7 +243,8 @@ public class NormalDistribution extends AbstractRealDistribution { public RealDistribution.Sampler createSampler(final UniformRandomProvider rng) { return new RealDistribution.Sampler() { private final ContinuousSampler sampler = - new BoxMullerGaussianSampler(rng, mean, standardDeviation); + new GaussianSampler(new MarsagliaNormalizedGaussianSampler(rng), + mean, standardDeviation); /**{@inheritDoc} */ @Override http://git-wip-us.apache.org/repos/asf/commons-math/blob/cc26f76a/src/test/java/org/apache/commons/math4/filter/KalmanFilterTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/filter/KalmanFilterTest.java b/src/test/java/org/apache/commons/math4/filter/KalmanFilterTest.java index 686da6c..3bb50cb 100644 --- a/src/test/java/org/apache/commons/math4/filter/KalmanFilterTest.java +++ b/src/test/java/org/apache/commons/math4/filter/KalmanFilterTest.java @@ -392,7 +392,7 @@ public class KalmanFilterTest { final MeasurementModel mm = new DefaultMeasurementModel(H, R); final KalmanFilter filter = new KalmanFilter(pm, mm); - final RealDistribution.Sampler dist = new NormalDistribution(0, measurementNoise).createSampler(RandomSource.create(RandomSource.WELL_19937_C, 1000)); + final RealDistribution.Sampler dist = new NormalDistribution(0, measurementNoise).createSampler(RandomSource.create(RandomSource.WELL_19937_C, 1001)); for (int i = 0; i < iterations; i++) { // get the "real" cannonball position http://git-wip-us.apache.org/repos/asf/commons-math/blob/cc26f76a/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java index 29466b6..5d4a4d7 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java @@ -262,7 +262,7 @@ public class LevenbergMarquardtOptimizerTest final double ySigma = 15; final double radius = 111.111; // The test is extremely sensitive to the seed. - final long seed = 59321761412L; + final long seed = 59321761414L; final RandomCirclePointGenerator factory = new RandomCirclePointGenerator(xCenter, yCenter, radius, xSigma, ySigma, http://git-wip-us.apache.org/repos/asf/commons-math/blob/cc26f76a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizerTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizerTest.java b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizerTest.java index 0a7090c..11785f0 100644 --- a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizerTest.java +++ b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizerTest.java @@ -94,7 +94,8 @@ public class MultiStartMultivariateOptimizerTest { { 0.9, 1.2 } , { 3.5, -2.3 } }); - UniformRandomProvider g = RandomSource.create(RandomSource.MT_64, 16069223052l); + // The test is extremely sensitive to the seed. + UniformRandomProvider g = RandomSource.create(RandomSource.MT_64, 16069223056L); RandomVectorGenerator generator = new UncorrelatedRandomVectorGenerator(2, new GaussianRandomGenerator(g)); int nbStarts = 10; @@ -108,10 +109,11 @@ public class MultiStartMultivariateOptimizerTest { new InitialGuess(new double[] { -1.2, 1.0 })); Assert.assertEquals(nbStarts, optimizer.getOptima().length); - Assert.assertEquals(rosenbrock.getCount(), optimizer.getEvaluations()); - Assert.assertTrue(optimizer.getEvaluations() > 900); - Assert.assertTrue(optimizer.getEvaluations() < 1200); - Assert.assertTrue(optimum.getValue() < 5e-5); + final int numEval = optimizer.getEvaluations(); + Assert.assertEquals(rosenbrock.getCount(), numEval); + Assert.assertTrue("numEval=" + numEval, numEval > 900); + Assert.assertTrue("numEval=" + numEval, numEval < 1200); + Assert.assertTrue("optimum=" + optimum.getValue(), optimum.getValue() < 5e-5); } private static class Rosenbrock implements MultivariateFunction { http://git-wip-us.apache.org/repos/asf/commons-math/blob/cc26f76a/src/test/java/org/apache/commons/math4/random/UncorrelatedRandomVectorGeneratorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/random/UncorrelatedRandomVectorGeneratorTest.java b/src/test/java/org/apache/commons/math4/random/UncorrelatedRandomVectorGeneratorTest.java index 120918b..19da6d3 100644 --- a/src/test/java/org/apache/commons/math4/random/UncorrelatedRandomVectorGeneratorTest.java +++ b/src/test/java/org/apache/commons/math4/random/UncorrelatedRandomVectorGeneratorTest.java @@ -37,12 +37,12 @@ public class UncorrelatedRandomVectorGeneratorTest { generator = new UncorrelatedRandomVectorGenerator(mean, standardDeviation, new GaussianRandomGenerator(RandomSource.create(RandomSource.MT, - 17399225432l))); + 17399225433L))); } @Test public void testMeanAndCorrelation() { - + // The test is extremely sensitive to the seed (cf. constructor). VectorialMean meanStat = new VectorialMean(mean.length); VectorialCovariance covStat = new VectorialCovariance(mean.length, true); for (int i = 0; i < 10000; ++i) {