You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Gary Gregory <ga...@gmail.com> on 2017/05/04 00:14:43 UTC

Fwd: [math] Depend on snapshot version of "Commons RNG".

Remember that you MUST update to a non-snapshot release before a release.

G
---------- Forwarded message ----------
From: <er...@apache.org>
Date: May 3, 2017 3:13 PM
Subject: [math] Depend on snapshot version of "Commons RNG".
To: <co...@commons.apache.org>
Cc:

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 <er...@apache.org>
Authored: Thu May 4 00:10:51 2017 +0200
Committer: Gilles <er...@apache.org>
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 @@
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-rng-sampling</artifactId>
-      <version>1.0</version>
+      <version>1.1-SNAPSHOT</version>
     </dependency>

     <dependency>

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 MarsagliaNormalizedGaussianSam
pler(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/MultiStartMultivariateOptimize
rTest.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) {

Re: Fwd: [math] Depend on snapshot version of "Commons RNG".

Posted by Gilles <gi...@harfang.homelinux.org>.
On Wed, 3 May 2017 17:14:43 -0700, Gary Gregory wrote:
> Remember that you MUST update to a non-snapshot release before a 
> release.

Surely the [VOTE] won't pass if that's still the case when the
time comes. ;-)

Gilles

> G
> ---------- Forwarded message ----------
> From: <er...@apache.org>
> Date: May 3, 2017 3:13 PM
> Subject: [math] Depend on snapshot version of "Commons RNG".
> To: <co...@commons.apache.org>
> Cc:
>
> 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.
>
> [...]


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org