You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2021/06/05 11:24:52 UTC

[commons-math] 01/02: Use "Commons RNG" (unit tests).

This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git

commit 7b9edac695c685c595b53df2ea4f7d00aa7386a3
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Sat Jun 5 03:41:14 2021 +0200

    Use "Commons RNG" (unit tests).
---
 .../math4/legacy/optim/nonlinear/scalar/noderiv/OptimTestUtils.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/OptimTestUtils.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/OptimTestUtils.java
index 2d5b4fa..5c3cb7b 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/OptimTestUtils.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/OptimTestUtils.java
@@ -17,9 +17,9 @@
 package org.apache.commons.math4.legacy.optim.nonlinear.scalar.noderiv;
 
 import java.util.Arrays;
-import java.util.Random;
 import org.apache.commons.rng.UniformRandomProvider;
 import org.apache.commons.rng.simple.RandomSource;
+import org.apache.commons.rng.sampling.distribution.MarsagliaNormalizedGaussianSampler;
 import org.apache.commons.math4.legacy.analysis.MultivariateFunction;
 import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
 
@@ -346,7 +346,7 @@ class OptimTestUtils {
 
     private static class Basis {
         double[][] basis;
-        final Random rand = new Random(2); // use not always the same basis
+        final MarsagliaNormalizedGaussianSampler rand = MarsagliaNormalizedGaussianSampler.of(rng()); // use not always the same basis
 
         double[] Rotate(double[] x) {
             GenBasis(x.length);
@@ -373,7 +373,7 @@ class OptimTestUtils {
             for (i = 0; i < DIM; ++i) {
                 /* sample components gaussian */
                 for (j = 0; j < DIM; ++j) {
-                    basis[i][j] = rand.nextGaussian();
+                    basis[i][j] = rand.sample();
                 }
                 /* substract projection of previous vectors */
                 for (j = i - 1; j >= 0; --j) {