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/14 20:28:59 UTC

[commons-math] branch master updated (24b1d86 -> b509678)

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

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


    from 24b1d86  MATH-1608: Remove random string generator.
     new ee73d63  MATH-1603: Userguide update.
     new b509678  MATH-1610: Functionality moved to "Commons RNG" (cf. RNG-145).

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../commons/math4/legacy/random/RandomUtils.java   |  84 ---------------
 .../RandomUtilsDataGeneratorAbstractTest.java      | 116 ---------------------
 src/site/xdoc/userguide/index.xml                  |   2 +-
 src/site/xdoc/userguide/transform.xml              |  23 ++--
 4 files changed, 12 insertions(+), 213 deletions(-)

[commons-math] 02/02: MATH-1610: Functionality moved to "Commons RNG" (cf. RNG-145).

Posted by er...@apache.org.
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 b509678e95f313d05bfdae6e38492b3dbb306b5a
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Mon Jun 14 22:26:22 2021 +0200

    MATH-1610: Functionality moved to "Commons RNG" (cf. RNG-145).
---
 .../commons/math4/legacy/random/RandomUtils.java   |  84 ---------------
 .../RandomUtilsDataGeneratorAbstractTest.java      | 116 ---------------------
 2 files changed, 200 deletions(-)

diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/random/RandomUtils.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/random/RandomUtils.java
index 35b8585..48d2464 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/random/RandomUtils.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/random/RandomUtils.java
@@ -97,89 +97,5 @@ public class RandomUtils {
                 return lower + rng.nextLong(max);
             }
         }
-
-        /**
-         * Generates a uniformly distributed random value from the open interval
-         * {@code (lower, upper)} (i.e., endpoints excluded).
-         * <p>
-         * <strong>Definition</strong>:
-         * <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda3662.htm">
-         * Uniform Distribution</a> {@code lower} and {@code upper - lower} are the
-         * <a href = "http://www.itl.nist.gov/div898/handbook/eda/section3/eda364.htm">
-         * location and scale parameters</a>, respectively.</p>
-         * <p>
-         * <strong>Algorithm Description</strong>: scales the output of
-         * Random.nextDouble(), but rejects 0 values (i.e., will generate another
-         * random double if Random.nextDouble() returns 0). This is necessary to
-         * provide a symmetric output interval (both endpoints excluded).
-         * </p>
-         *
-         * @param lower Lower bound of the support (excluded).
-         * @param upper Upper bound of the support (excluded).
-         * @return a uniformly distributed random value between lower and upper
-         * (both excluded).
-         * @throws NumberIsTooLargeException if {@code lower >= upper}.
-         * @throws NotFiniteNumberException if one of the bounds is infinite.
-         * @throws NotANumberException if one of the bounds is NaN.
-         */
-        public double nextUniform(double lower, double upper) {
-            return nextUniform(lower, upper, false);
-        }
-
-        /**
-         * Generates a uniformly distributed random value from the interval
-         * {@code (lower, upper)} or the interval {@code [lower, upper)}. The lower
-         * bound is thus optionally included, while the upper bound is always
-         * excluded.
-         * <p>
-         * <strong>Definition</strong>:
-         * <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda3662.htm">
-         * Uniform Distribution</a> {@code lower} and {@code upper - lower} are the
-         * <a href = "http://www.itl.nist.gov/div898/handbook/eda/section3/eda364.htm">
-         * location and scale parameters</a>, respectively.</p>
-         * <p>
-         * <strong>Algorithm Description</strong>: if the lower bound is excluded,
-         * scales the output of "nextDouble()", but rejects 0 values (i.e. it
-         * will generate another random double if "nextDouble()" returns 0).
-         * This is necessary to provide a symmetric output interval (both
-         * endpoints excluded).
-         * </p>
-         *
-         * @param lower Lower bound of the support.
-         * @param upper Exclusive upper bound of the support.
-         * @param lowerInclusive {@code true} if the lower bound is inclusive.
-         * @return a uniformly distributed random value in the {@code (lower, upper)}
-         * interval, if {@code lowerInclusive} is {@code false}, or in the
-         * {@code [lower, upper)} interval, if {@code lowerInclusive} is
-         * {@code true}.
-         * @throws NumberIsTooLargeException if {@code lower >= upper}.
-         * @throws NotFiniteNumberException if one of the bounds is infinite.
-         * @throws NotANumberException if one of the bounds is NaN.
-         */
-        public double nextUniform(double lower,
-                                  double upper,
-                                  boolean lowerInclusive) {
-            if (lower >= upper) {
-                throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
-                                                    lower, upper, false);
-            }
-            if (Double.isInfinite(lower)) {
-                throw new NotFiniteNumberException(LocalizedFormats.INFINITE_BOUND, lower);
-            }
-            if (Double.isInfinite(upper)) {
-                throw new NotFiniteNumberException(LocalizedFormats.INFINITE_BOUND, upper);
-            }
-            if (Double.isNaN(lower) || Double.isNaN(upper)) {
-                throw new NotANumberException();
-            }
-
-            // Ensure nextDouble() isn't 0.0
-            double u = rng.nextDouble();
-            while (!lowerInclusive && u <= 0.0) {
-                u = rng.nextDouble();
-            }
-
-            return u * upper + (1.0 - u) * lower;
-        }
     }
 }
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/RandomUtilsDataGeneratorAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/RandomUtilsDataGeneratorAbstractTest.java
index 1edb371..c1f611a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/RandomUtilsDataGeneratorAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/RandomUtilsDataGeneratorAbstractTest.java
@@ -52,17 +52,6 @@ public abstract class RandomUtilsDataGeneratorAbstractTest {
     }
 
     @Test
-    public void testNextUniformExtremeValues() {
-        double x = randomData.nextUniform(-Double.MAX_VALUE, Double.MAX_VALUE);
-        double y = randomData.nextUniform(-Double.MAX_VALUE, Double.MAX_VALUE);
-        Assert.assertFalse(x == y);
-        Assert.assertFalse(Double.isNaN(x));
-        Assert.assertFalse(Double.isNaN(y));
-        Assert.assertFalse(Double.isInfinite(x));
-        Assert.assertFalse(Double.isInfinite(y));
-    }
-
-    @Test
     public void testNextLongIAE() {
         try {
             randomData.nextLong(4, 3);
@@ -136,109 +125,4 @@ public abstract class RandomUtilsDataGeneratorAbstractTest {
                        (((double) upper) - ((double) lower));
         Assert.assertTrue(ratio > 0.99999);
     }
-
-    @Test
-    public void testNextUniformIAE() {
-        try {
-            randomData.nextUniform(4, 3);
-            Assert.fail("MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        try {
-            randomData.nextUniform(0, Double.POSITIVE_INFINITY);
-            Assert.fail("MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        try {
-            randomData.nextUniform(Double.NEGATIVE_INFINITY, 0);
-            Assert.fail("MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        try {
-            randomData.nextUniform(0, Double.NaN);
-            Assert.fail("MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        try {
-            randomData.nextUniform(Double.NaN, 0);
-            Assert.fail("MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-    }
-
-    @Test
-    public void testNextUniformPositiveBounds() {
-        for (int i = 0; i < 5; i++) {
-            checkNextUniform(0, 10);
-        }
-    }
-
-    @Test
-    public void testNextUniformNegativeToPositiveBounds() {
-        for (int i = 0; i < 5; i++) {
-            checkNextUniform(-3, 5);
-        }
-    }
-
-    @Test
-    public void testNextUniformNegativeBounds() {
-        for (int i = 0; i < 5; i++) {
-            checkNextUniform(-7, -3);
-        }
-    }
-
-    @Test
-    public void testNextUniformMaximalInterval() {
-        for (int i = 0; i < 5; i++) {
-            checkNextUniform(-Double.MAX_VALUE, Double.MAX_VALUE);
-        }
-    }
-
-    private void checkNextUniform(double min, double max) {
-        // Set up bin bounds - min, binBound[0], ..., binBound[binCount-2], max
-        final int binCount = 5;
-        final double binSize = max / binCount - min/binCount; // Prevent overflow in extreme value case
-        final double[] binBounds = new double[binCount - 1];
-        binBounds[0] = min + binSize;
-        for (int i = 1; i < binCount - 1; i++) {
-            binBounds[i] = binBounds[i - 1] + binSize;  // + instead of * to avoid overflow in extreme case
-        }
-
-        final Frequency<Integer> freq = new Frequency<>();
-        for (int i = 0; i < smallSampleSize; i++) {
-            final double value = randomData.nextUniform(min, max);
-            Assert.assertTrue("nextUniform range", (value > min) && (value < max));
-            // Find bin
-            int j = 0;
-            while (j < binCount - 1 && value > binBounds[j]) {
-                j++;
-            }
-            freq.addValue(j);
-        }
-
-        final long[] observed = new long[binCount];
-        for (int i = 0; i < binCount; i++) {
-            observed[i] = freq.getCount(i);
-        }
-        final double[] expected = new double[binCount];
-        for (int i = 0; i < binCount; i++) {
-            expected[i] = 1d / binCount;
-        }
-
-        TestUtils.assertChiSquareAccept(expected, observed, 0.01);
-    }
-
-    /** test exclusive endpoints of nextUniform **/
-    @Test
-    public void testNextUniformExclusiveEndpoints() {
-        for (int i = 0; i < 1000; i++) {
-            double u = randomData.nextUniform(0.99, 1);
-            Assert.assertTrue(u > 0.99 && u < 1);
-        }
-    }
 }

[commons-math] 01/02: MATH-1603: Userguide update.

Posted by er...@apache.org.
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 ee73d636dea9618c685755111a98e65e1cbc5049
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Mon Jun 14 20:32:40 2021 +0200

    MATH-1603: Userguide update.
---
 src/site/xdoc/userguide/index.xml     |  2 +-
 src/site/xdoc/userguide/transform.xml | 23 +++++++++++------------
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/src/site/xdoc/userguide/index.xml b/src/site/xdoc/userguide/index.xml
index 8211a88..0ad64fd 100644
--- a/src/site/xdoc/userguide/index.xml
+++ b/src/site/xdoc/userguide/index.xml
@@ -99,7 +99,7 @@
                 <ul>
                 <li><a href="fraction.html#a9.1_Overview">9.1 Overview</a></li>
                 </ul></li>                                 
-        <li><a href="transform.html">10. Transform methods</a></li>                                 
+        <li><a href="transform.html">10. Transforms</a></li>
         <li><a href="geometry.html">11. Geometry</a>
                 <ul>
                 <li><a href="geometry.html#a11.1_Overview">11.1 Overview</a></li>
diff --git a/src/site/xdoc/userguide/transform.xml b/src/site/xdoc/userguide/transform.xml
index 56cdec0..c2ad958 100644
--- a/src/site/xdoc/userguide/transform.xml
+++ b/src/site/xdoc/userguide/transform.xml
@@ -21,23 +21,22 @@
 <document url="transform.html">
 
   <properties>
-    <title>The Commons Math User Guide - Transform methods</title>
+    <title>The Commons Math User Guide - Transforms</title>
   </properties>
 
   <body>
-    <section name="10 Transform methods">
+    <section name="10 Transforms">
       <p>
-         This package provides a few transformers for signal analysis. All transformers
-         provide both direct and inverse transforms.
+         Function transforms (direct and inverse) for signal analysis.
          <ul>
-           <li><a href="../apidocs/org/apache/commons/math4/transform/FastFourierTransformer.html">
-            FastFourierTransformer</a> (produces <code>Complex</code> results)</li>
-           <li><a href="../apidocs/org/apache/commons/math4/transform/FastCosineTransformer.html">
-           FastCosineTransformer</a> (produces real results)</li>
-           <li><a href="../apidocs/org/apache/commons/math4/transform/FastSineTransformer.html">
-           FastSineTransformer</a> (produces real results)</li>
-           <li><a href="../apidocs/org/apache/commons/math4/transform/FastHadamardTransformer.html">
-           FastHadamardTransformer</a> (produces real results)</li>
+           <li><a href="../commons-math4-transform/apidocs/org/apache/commons/math4/transform/FastFourierTransform.html">
+            FastFourierTransform</a> (produces <code>Complex</code> results)</li>
+           <li><a href="../commons-math4-transform/apidocs/org/apache/commons/math4/transform/FastCosineTransform.html">
+            FastCosineTransform</a> (produces real results)</li>
+           <li><a href="../commons-math4-transform/apidocs/org/apache/commons/math4/transform/FastSineTransform.html">
+            FastSineTransform</a> (produces real results)</li>
+           <li><a href="../commons-math4-transform/apidocs/org/apache/commons/math4/transform/FastHadamardTransform.html">
+            FastHadamardTransform</a> (produces real results)</li>
          </ul>
       </p>
      </section>