You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2021/08/13 19:32:00 UTC

[commons-rng] branch master updated (df6844c -> da20fc8)

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

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


    from df6844c  Update JDK 9 to 11 in travis
     new c04f9da  RNG-162: Update Java from 1.7 to 1.8
     new 54bf160  Move Java 8 profile plugins to the main pom
     new 1980c1c  Drop clirr plugin. It is superceded by japicmp
     new d04082e  Use JDK 8 Double.isFinite and Math.nextUp/Down
     new 15afa33  Use Objects.requireNonNull
     new 8b0059c  Use java.util.function.DoubleUnaryOperator
     new 87bb55f  Update minimum java version in documentation
     new 9271497  Update minimum java version in chamges log
     new e98e510  Update examples/release profiles to require java 11
     new 3a17ec3  Update description of java requirements in the user guide
     new d7be418  Use lambdas
     new da20fc8  Replace benchmarking interfaces with java.util.function

The 12 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:
 .../src/site/resources/profile.clirr               |  17 --
 commons-rng-core/src/site/resources/profile.clirr  |  17 --
 .../jmh/sampling/UnitSphereSamplerBenchmark.java   | 101 +++------
 .../EnumeratedDistributionSamplersPerformance.java |  82 ++-----
 .../PoissonSamplerCachePerformance.java            |  40 +---
 .../distribution/PoissonSamplersPerformance.java   |  77 ++-----
 .../distribution/StableSamplerPerformance.java     | 154 ++++---------
 .../distribution/ZigguratSamplerPerformance.java   |  43 +---
 .../shape/TetrahedronSamplerBenchmark.java         |  42 ++--
 .../sampling/shape/TriangleSamplerBenchmark.java   | 143 +++++-------
 .../sampling/shape/UnitBallSamplerBenchmark.java   |  92 ++------
 commons-rng-examples/examples-sampling/pom.xml     |   3 -
 commons-rng-examples/examples-stress/pom.xml       |   3 -
 .../commons/rng/sampling/CompositeSamplers.java    |  28 +--
 .../rng/sampling/distribution/GaussianSampler.java |   3 +-
 .../sampling/distribution/PoissonSamplerCache.java |   2 +-
 .../rng/sampling/distribution/StableSampler.java   |   3 +-
 .../commons/rng/sampling/shape/Coordinates.java    |  13 +-
 .../src/site/resources/profile.clirr               |  17 --
 .../rng/sampling/UnitSphereSamplerTest.java        |   2 +-
 .../distribution/ContinuousUniformSamplerTest.java |  10 +-
 .../distribution/GeometricSamplerTest.java         |   2 +-
 .../distribution/LargeMeanPoissonSamplerTest.java  |   2 +-
 .../MarsagliaTsangWangDiscreteSamplerTest.java     |   4 +-
 .../distribution/PoissonSamplerCacheTest.java      |  18 +-
 .../sampling/distribution/StableSamplerTest.java   |  98 +++------
 .../rng/sampling/shape/UnitBallSamplerTest.java    | 110 ++--------
 .../src/site/resources/profile.clirr               |  17 --
 pom.xml                                            | 240 ++++++++-------------
 src/changes/changes.xml                            |  18 +-
 src/site/apt/userguide/rng.apt                     |  18 +-
 31 files changed, 392 insertions(+), 1027 deletions(-)
 delete mode 100644 commons-rng-client-api/src/site/resources/profile.clirr
 delete mode 100644 commons-rng-core/src/site/resources/profile.clirr
 delete mode 100644 commons-rng-sampling/src/site/resources/profile.clirr
 delete mode 100644 commons-rng-simple/src/site/resources/profile.clirr

[commons-rng] 05/12: Use Objects.requireNonNull

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 15afa3328890b2e47ab8eb872c369872968b0417
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Aug 13 19:34:01 2021 +0100

    Use Objects.requireNonNull
---
 .../commons/rng/sampling/CompositeSamplers.java    | 28 ++++------------------
 1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CompositeSamplers.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CompositeSamplers.java
index 7de1acf..b8941ee 100644
--- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CompositeSamplers.java
+++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CompositeSamplers.java
@@ -18,6 +18,7 @@
 package org.apache.commons.rng.sampling;
 
 import java.util.List;
+import java.util.Objects;
 import java.util.ArrayList;
 
 import org.apache.commons.rng.UniformRandomProvider;
@@ -141,7 +142,7 @@ public final class CompositeSamplers {
         SharedStateDiscreteProbabilitySampler(DiscreteSampler sampler,
                                               DiscreteProbabilitySamplerFactory factory,
                                               double[] probabilities) {
-            this.sampler = requireNonNull(sampler, "discrete sampler");
+            this.sampler = Objects.requireNonNull(sampler, "discrete sampler");
             // Assume the factory and probabilities are not null
             this.factory = factory;
             this.probabilities = probabilities;
@@ -308,7 +309,7 @@ public final class CompositeSamplers {
              */
             WeightedSampler(double weight, S sampler) {
                 this.weight = requirePositiveFinite(weight, "weight");
-                this.sampler = requireNonNull(sampler, "sampler");
+                this.sampler = Objects.requireNonNull(sampler, "sampler");
             }
 
             /**
@@ -382,7 +383,7 @@ public final class CompositeSamplers {
          */
         @Override
         public Builder<S> setFactory(DiscreteProbabilitySamplerFactory samplerFactory) {
-            this.factory = requireNonNull(samplerFactory, "factory");
+            this.factory = Objects.requireNonNull(samplerFactory, "factory");
             return this;
         }
 
@@ -1055,27 +1056,6 @@ public final class CompositeSamplers {
     }
 
     /**
-     * Checks that the specified object reference is not {@code null} and throws a
-     * customized {@link NullPointerException} if it is.
-     *
-     * <P>Note: This method is to be replaced with
-     * {@code java.util.Objects.requireNonNull} when the source requires Java 8.
-     *
-     * @param obj the object reference to check for nullity
-     * @param message detail message to be used in the event that a {@code
-     *                NullPointerException} is thrown
-     * @param <T> the type of the reference
-     * @return {@code obj} if not {@code null}
-     * @throws NullPointerException if {@code obj} is {@code null}
-     */
-    private static <T> T requireNonNull(T obj, String message) {
-        if (obj == null) {
-            throw new NullPointerException(message);
-        }
-        return obj;
-    }
-
-    /**
      * Create a copy instance of each sampler in the list of samplers using the given
      * uniform random provider as the source of randomness.
      *

[commons-rng] 12/12: Replace benchmarking interfaces with java.util.function

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit da20fc81d265df172d595e70d5debf1f9d694a17
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Aug 13 20:31:42 2021 +0100

    Replace benchmarking interfaces with java.util.function
---
 .../jmh/sampling/UnitSphereSamplerBenchmark.java   | 49 +++++++---------------
 .../EnumeratedDistributionSamplersPerformance.java | 19 ++-------
 .../PoissonSamplerCachePerformance.java            | 25 +++--------
 .../distribution/PoissonSamplersPerformance.java   | 19 ++-------
 .../distribution/ZigguratSamplerPerformance.java   | 11 +----
 .../shape/TetrahedronSamplerBenchmark.java         | 29 ++++---------
 .../sampling/shape/TriangleSamplerBenchmark.java   | 39 +++++++----------
 .../sampling/shape/UnitBallSamplerBenchmark.java   | 33 +++++----------
 8 files changed, 65 insertions(+), 159 deletions(-)

diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/UnitSphereSamplerBenchmark.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/UnitSphereSamplerBenchmark.java
index 154d281..9ecc68a 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/UnitSphereSamplerBenchmark.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/UnitSphereSamplerBenchmark.java
@@ -18,6 +18,7 @@
 package org.apache.commons.rng.examples.jmh.sampling;
 
 import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.sampling.ObjectSampler;
 import org.apache.commons.rng.sampling.distribution.NormalizedGaussianSampler;
 import org.apache.commons.rng.sampling.distribution.ZigguratSampler;
 import org.apache.commons.rng.simple.RandomSource;
@@ -56,18 +57,6 @@ public class UnitSphereSamplerBenchmark {
     private static final String UNKNOWN_SAMPLER = "Unknown sampler type: ";
 
     /**
-     * The sampler.
-     */
-    private interface Sampler {
-        /**
-         * Gets the next sample.
-         *
-         * @return the sample
-         */
-        double[] sample();
-    }
-
-    /**
      * Base class for the sampler data.
      * Contains the source of randomness and the number of samples.
      * The sampler should be created by a sub-class of the data.
@@ -75,7 +64,7 @@ public class UnitSphereSamplerBenchmark {
     @State(Scope.Benchmark)
     public abstract static class SamplerData {
         /** The sampler. */
-        private Sampler sampler;
+        private ObjectSampler<double[]> sampler;
 
         /** The number of samples. */
         @Param({"100"})
@@ -95,7 +84,7 @@ public class UnitSphereSamplerBenchmark {
          *
          * @return the sampler
          */
-        public Sampler getSampler() {
+        public ObjectSampler<double[]> getSampler() {
             return sampler;
         }
 
@@ -115,7 +104,7 @@ public class UnitSphereSamplerBenchmark {
          * @param rng the source of randomness
          * @return the sampler
          */
-        protected abstract Sampler createSampler(UniformRandomProvider rng);
+        protected abstract ObjectSampler<double[]> createSampler(UniformRandomProvider rng);
     }
 
     /**
@@ -142,7 +131,7 @@ public class UnitSphereSamplerBenchmark {
 
         /** {@inheritDoc} */
         @Override
-        protected Sampler createSampler(final UniformRandomProvider rng) {
+        protected ObjectSampler<double[]> createSampler(final UniformRandomProvider rng) {
             if (BASELINE.equals(type)) {
                 return () -> {
                     return new double[] {1.0};
@@ -185,11 +174,9 @@ public class UnitSphereSamplerBenchmark {
 
         /** {@inheritDoc} */
         @Override
-        protected Sampler createSampler(final UniformRandomProvider rng) {
+        protected ObjectSampler<double[]> createSampler(final UniformRandomProvider rng) {
             if (BASELINE.equals(type)) {
-                return () -> {
-                    return new double[] {1.0, 0.0};
-                };
+                return () -> new double[] {1.0, 0.0};
             } else if (ARRAY.equals(type)) {
                 return new ArrayBasedUnitSphereSampler(2, rng);
             } else if (NON_ARRAY.equals(type)) {
@@ -201,7 +188,7 @@ public class UnitSphereSamplerBenchmark {
         /**
          * Sample from a 2D unit sphere.
          */
-        private static class UnitSphereSampler2D implements Sampler {
+        private static class UnitSphereSampler2D implements ObjectSampler<double[]> {
             /** Sampler used for generating the individual components of the vectors. */
             private final NormalizedGaussianSampler sampler;
 
@@ -240,11 +227,9 @@ public class UnitSphereSamplerBenchmark {
 
         /** {@inheritDoc} */
         @Override
-        protected Sampler createSampler(final UniformRandomProvider rng) {
+        protected ObjectSampler<double[]> createSampler(final UniformRandomProvider rng) {
             if (BASELINE.equals(type)) {
-                return () -> {
-                    return new double[] {1.0, 0.0, 0.0};
-                };
+                return () -> new double[] {1.0, 0.0, 0.0};
             } else if (ARRAY.equals(type)) {
                 return new ArrayBasedUnitSphereSampler(3, rng);
             } else if (NON_ARRAY.equals(type)) {
@@ -256,7 +241,7 @@ public class UnitSphereSamplerBenchmark {
         /**
          * Sample from a 3D unit sphere.
          */
-        private static class UnitSphereSampler3D implements Sampler {
+        private static class UnitSphereSampler3D implements ObjectSampler<double[]> {
             /** Sampler used for generating the individual components of the vectors. */
             private final NormalizedGaussianSampler sampler;
 
@@ -296,11 +281,9 @@ public class UnitSphereSamplerBenchmark {
 
         /** {@inheritDoc} */
         @Override
-        protected Sampler createSampler(final UniformRandomProvider rng) {
+        protected ObjectSampler<double[]> createSampler(final UniformRandomProvider rng) {
             if (BASELINE.equals(type)) {
-                return () -> {
-                    return new double[] {1.0, 0.0, 0.0, 0.0};
-                };
+                return () -> new double[] {1.0, 0.0, 0.0, 0.0};
             } else if (ARRAY.equals(type)) {
                 return new ArrayBasedUnitSphereSampler(4, rng);
             } else if (NON_ARRAY.equals(type)) {
@@ -312,7 +295,7 @@ public class UnitSphereSamplerBenchmark {
         /**
          * Sample from a 4D unit hypersphere.
          */
-        private static class UnitSphereSampler4D implements Sampler {
+        private static class UnitSphereSampler4D implements ObjectSampler<double[]> {
             /** Sampler used for generating the individual components of the vectors. */
             private final NormalizedGaussianSampler sampler;
 
@@ -345,7 +328,7 @@ public class UnitSphereSamplerBenchmark {
     /**
      * Sample from a unit sphere using an array based method.
      */
-    private static class ArrayBasedUnitSphereSampler implements Sampler {
+    private static class ArrayBasedUnitSphereSampler implements ObjectSampler<double[]> {
         /** Space dimension. */
         private final int dimension;
         /** Sampler used for generating the individual components of the vectors. */
@@ -394,7 +377,7 @@ public class UnitSphereSamplerBenchmark {
      * @param data Input data.
      */
     private static void runSampler(Blackhole bh, SamplerData data) {
-        final Sampler sampler = data.getSampler();
+        final ObjectSampler<double[]> sampler = data.getSampler();
         for (int i = data.getSize() - 1; i >= 0; i--) {
             bh.consume(sampler.sample());
         }
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/EnumeratedDistributionSamplersPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/EnumeratedDistributionSamplersPerformance.java
index 2828f44..c2a7033 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/EnumeratedDistributionSamplersPerformance.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/EnumeratedDistributionSamplersPerformance.java
@@ -43,6 +43,7 @@ import org.openjdk.jmh.annotations.Warmup;
 import java.util.Arrays;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.TimeUnit;
+import java.util.function.Supplier;
 
 /**
  * Executes benchmark to compare the speed of generation of random numbers from an enumerated
@@ -128,24 +129,12 @@ public class EnumeratedDistributionSamplersPerformance {
         private String samplerType;
 
         /** The factory. */
-        private DiscreteSamplerFactory factory;
+        private Supplier<DiscreteSampler> factory;
 
         /** The sampler. */
         private DiscreteSampler sampler;
 
         /**
-         * A factory for creating DiscreteSampler objects.
-         */
-        interface DiscreteSamplerFactory {
-            /**
-             * Creates the sampler.
-             *
-             * @return the sampler
-             */
-            DiscreteSampler create();
-        }
-
-        /**
          * Gets the sampler.
          *
          * @return the sampler.
@@ -162,7 +151,7 @@ public class EnumeratedDistributionSamplersPerformance {
 
             final double[] probabilities = createProbabilities();
             createSamplerFactory(getGenerator(), probabilities);
-            sampler = factory.create();
+            sampler = factory.get();
         }
 
         /**
@@ -210,7 +199,7 @@ public class EnumeratedDistributionSamplersPerformance {
          * @return The sampler.
          */
         public DiscreteSampler createSampler() {
-            return factory.create();
+            return factory.get();
         }
     }
 
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplerCachePerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplerCachePerformance.java
index 4495374..6cffb72 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplerCachePerformance.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplerCachePerformance.java
@@ -18,7 +18,7 @@
 package org.apache.commons.rng.examples.jmh.sampling.distribution;
 
 import java.util.concurrent.TimeUnit;
-
+import java.util.function.DoubleFunction;
 import org.apache.commons.rng.RandomProviderState;
 import org.apache.commons.rng.RestorableUniformRandomProvider;
 import org.apache.commons.rng.UniformRandomProvider;
@@ -268,30 +268,17 @@ public class PoissonSamplerCachePerformance {
     }
 
     /**
-     * A factory for creating Poisson sampler objects.
-     */
-    private interface PoissonSamplerFactory {
-        /**
-         * Creates a new Poisson sampler object.
-         *
-         * @param mean the mean
-         * @return The sampler
-         */
-        DiscreteSampler createPoissonSampler(double mean);
-    }
-
-    /**
      * Exercises a poisson sampler created for a single use with a range of means.
      *
      * @param factory The factory.
      * @param range   The range of means.
      * @param bh      Data sink.
      */
-    private static void runSample(PoissonSamplerFactory factory,
+    private static void runSample(DoubleFunction<DiscreteSampler> factory,
                                   MeanRange range,
                                   Blackhole bh) {
         for (int i = 0; i < NUM_SAMPLES; i++) {
-            bh.consume(factory.createPoissonSampler(range.getMean(i)).sample());
+            bh.consume(factory.apply(range.getMean(i)).sample());
         }
     }
 
@@ -307,7 +294,7 @@ public class PoissonSamplerCachePerformance {
                                   MeanRange range,
                                   Blackhole bh) {
         final UniformRandomProvider r = sources.getGenerator();
-        final PoissonSamplerFactory factory = mean -> PoissonSampler.of(r, mean);
+        final DoubleFunction<DiscreteSampler> factory = mean -> PoissonSampler.of(r, mean);
         runSample(factory, range, bh);
     }
 
@@ -322,7 +309,7 @@ public class PoissonSamplerCachePerformance {
                                                 Blackhole bh) {
         final UniformRandomProvider r = sources.getGenerator();
         final PoissonSamplerCache cache = new PoissonSamplerCache(0, 0);
-        final PoissonSamplerFactory factory = mean -> cache.createSharedStateSampler(r, mean);
+        final DoubleFunction<DiscreteSampler> factory = mean -> cache.createSharedStateSampler(r, mean);
         runSample(factory, range, bh);
     }
 
@@ -338,7 +325,7 @@ public class PoissonSamplerCachePerformance {
         final UniformRandomProvider r = sources.getGenerator();
         final PoissonSamplerCache cache = new PoissonSamplerCache(
                 range.getMin(), range.getMax());
-        final PoissonSamplerFactory factory = mean -> cache.createSharedStateSampler(r, mean);
+        final DoubleFunction<DiscreteSampler> factory = mean -> cache.createSharedStateSampler(r, mean);
         runSample(factory, range, bh);
     }
 }
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplersPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplersPerformance.java
index 8537431..54e704b 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplersPerformance.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplersPerformance.java
@@ -37,6 +37,7 @@ import org.openjdk.jmh.annotations.State;
 import org.openjdk.jmh.annotations.Warmup;
 
 import java.util.concurrent.TimeUnit;
+import java.util.function.Supplier;
 
 /**
  * Executes benchmark to compare the speed of generation of Poisson distributed random numbers.
@@ -136,24 +137,12 @@ public class PoissonSamplersPerformance {
         private UniformRandomProvider generator;
 
         /** The factory. */
-        private DiscreteSamplerFactory factory;
+        private Supplier<DiscreteSampler> factory;
 
         /** The sampler. */
         private DiscreteSampler sampler;
 
         /**
-         * A factory for creating DiscreteSampler objects.
-         */
-        interface DiscreteSamplerFactory {
-            /**
-             * Creates the sampler.
-             *
-             * @return the sampler
-             */
-            DiscreteSampler create();
-        }
-
-        /**
          * @return The RNG.
          */
         public UniformRandomProvider getGenerator() {
@@ -193,7 +182,7 @@ public class PoissonSamplersPerformance {
             } else if ("TinyMeanPoissonSampler".equals(samplerType)) {
                 factory = () -> new TinyMeanPoissonSampler(generator, mean);
             }
-            sampler = factory.create();
+            sampler = factory.get();
         }
 
         /**
@@ -202,7 +191,7 @@ public class PoissonSamplersPerformance {
          * @return The sampler.
          */
         public DiscreteSampler createSampler() {
-            return factory.create();
+            return factory.get();
         }
     }
 
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ZigguratSamplerPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ZigguratSamplerPerformance.java
index 59a845a..da961d5 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ZigguratSamplerPerformance.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ZigguratSamplerPerformance.java
@@ -20,6 +20,7 @@ package org.apache.commons.rng.examples.jmh.sampling.distribution;
 import org.apache.commons.rng.UniformRandomProvider;
 import org.apache.commons.rng.sampling.distribution.ContinuousSampler;
 import org.apache.commons.rng.sampling.distribution.DiscreteSampler;
+import org.apache.commons.rng.sampling.distribution.LongSampler;
 import org.apache.commons.rng.sampling.distribution.ZigguratSampler;
 import org.apache.commons.rng.sampling.distribution.ZigguratNormalizedGaussianSampler;
 import org.apache.commons.rng.simple.RandomSource;
@@ -149,16 +150,6 @@ public class ZigguratSamplerPerformance {
     }
 
     /**
-     * Sampler that generates values of type {@code long}.
-     */
-    interface LongSampler {
-        /**
-         * @return a sample.
-         */
-        long sample();
-    }
-
-    /**
      * Defines method to use for creating unsigned {@code long} values.
      */
     @State(Scope.Benchmark)
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TetrahedronSamplerBenchmark.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TetrahedronSamplerBenchmark.java
index 5a5f858..2251566 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TetrahedronSamplerBenchmark.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TetrahedronSamplerBenchmark.java
@@ -18,6 +18,7 @@
 package org.apache.commons.rng.examples.jmh.sampling.shape;
 
 import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.sampling.ObjectSampler;
 import org.apache.commons.rng.sampling.UnitSphereSampler;
 import org.apache.commons.rng.simple.RandomSource;
 import org.openjdk.jmh.annotations.Benchmark;
@@ -59,18 +60,6 @@ public class TetrahedronSamplerBenchmark {
     private static final String UNKNOWN_SAMPLER = "Unknown sampler type: ";
 
     /**
-     * The sampler.
-     */
-    private interface Sampler {
-        /**
-         * Gets the next sample.
-         *
-         * @return a random Cartesian point within the tetrahedron.
-         */
-        double[] sample();
-    }
-
-    /**
      * The base class for sampling from a tetrahedron.
      *
      * <ul>
@@ -87,7 +76,7 @@ public class TetrahedronSamplerBenchmark {
      * @see <a href="https://doi.org/10.1080/10867651.2000.10487528">
      *   Rocchini, C. &amp; Cignoni, P. (2001) Journal of Graphics Tools 5, pp. 9-12</a>
      */
-    private abstract static class TetrahedronSampler implements Sampler {
+    private abstract static class TetrahedronSampler implements ObjectSampler<double[]> {
         /** The source of randomness. */
         private final UniformRandomProvider rng;
 
@@ -242,7 +231,7 @@ public class TetrahedronSamplerBenchmark {
      * Sample from a tetrahedron using array coordinates with an inline sample algorithm
      * in-place of a method call.
      */
-    private static class ArrayInlineTetrahedronSampler implements Sampler {
+    private static class ArrayInlineTetrahedronSampler implements ObjectSampler<double[]> {
         // CHECKSTYLE: stop JavadocVariableCheck
         private final double[] a;
         private final double[] b;
@@ -310,7 +299,7 @@ public class TetrahedronSamplerBenchmark {
      * Sample from a tetrahedron using non-array coordinates with an inline sample algorithm
      * in-place of a method call.
      */
-    private static class NonArrayInlineTetrahedronSampler implements Sampler {
+    private static class NonArrayInlineTetrahedronSampler implements ObjectSampler<double[]> {
         // CHECKSTYLE: stop JavadocVariableCheck
         private final double ax;
         private final double bx;
@@ -396,7 +385,7 @@ public class TetrahedronSamplerBenchmark {
     @State(Scope.Benchmark)
     public static class SamplerData {
         /** The sampler. */
-        private Sampler sampler;
+        private ObjectSampler<double[]> sampler;
 
         /** The number of samples. */
         @Param({"1", "10", "100", "1000", "10000"})
@@ -420,7 +409,7 @@ public class TetrahedronSamplerBenchmark {
          *
          * @return the sampler
          */
-        public Sampler getSampler() {
+        public ObjectSampler<double[]> getSampler() {
             return sampler;
         }
 
@@ -449,8 +438,8 @@ public class TetrahedronSamplerBenchmark {
          * @param rng the source of randomness
          * @return the sampler
          */
-        private Sampler createSampler(final UniformRandomProvider rng,
-                                      double[] a, double[] b, double[] c, double[] d) {
+        private ObjectSampler<double[]> createSampler(final UniformRandomProvider rng,
+                                                      double[] a, double[] b, double[] c, double[] d) {
             if (BASELINE.equals(type)) {
                 return () -> {
                     final double s = rng.nextDouble();
@@ -479,7 +468,7 @@ public class TetrahedronSamplerBenchmark {
      */
     @Benchmark
     public void sample(Blackhole bh, SamplerData data) {
-        final Sampler sampler = data.getSampler();
+        final ObjectSampler<double[]> sampler = data.getSampler();
         for (int i = data.getSize() - 1; i >= 0; i--) {
             bh.consume(sampler.sample());
         }
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TriangleSamplerBenchmark.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TriangleSamplerBenchmark.java
index 67632e9..d033264 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TriangleSamplerBenchmark.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TriangleSamplerBenchmark.java
@@ -18,6 +18,7 @@
 package org.apache.commons.rng.examples.jmh.sampling.shape;
 
 import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.sampling.ObjectSampler;
 import org.apache.commons.rng.sampling.UnitSphereSampler;
 import org.apache.commons.rng.simple.RandomSource;
 import org.openjdk.jmh.annotations.Benchmark;
@@ -57,21 +58,9 @@ public class TriangleSamplerBenchmark {
     private static final String UNKNOWN_SAMPLER = "Unknown sampler type: ";
 
     /**
-     * The sampler.
-     */
-    private interface Sampler {
-        /**
-         * Gets the next sample.
-         *
-         * @return the sample
-         */
-        double[] sample();
-    }
-
-    /**
      * Base class for a sampler using vectors: {@code p = a + sv + tw}.
      */
-    private abstract static class VectorTriangleSampler implements Sampler {
+    private abstract static class VectorTriangleSampler implements ObjectSampler<double[]> {
         /** The source of randomness. */
         private final UniformRandomProvider rng;
 
@@ -115,7 +104,7 @@ public class TriangleSamplerBenchmark {
     /**
      * Base class for a sampler using coordinates: {@code a(1 - s - t) + sb + tc}.
      */
-    private abstract static class CoordinateTriangleSampler implements Sampler {
+    private abstract static class CoordinateTriangleSampler implements ObjectSampler<double[]> {
         /** The source of randomness. */
         private final UniformRandomProvider rng;
 
@@ -172,7 +161,7 @@ public class TriangleSamplerBenchmark {
     @State(Scope.Benchmark)
     public abstract static class SamplerData {
         /** The sampler. */
-        private Sampler sampler;
+        private ObjectSampler<double[]> sampler;
 
         /** The number of samples. */
         @Param({"1000"})
@@ -192,7 +181,7 @@ public class TriangleSamplerBenchmark {
          *
          * @return the sampler
          */
-        public Sampler getSampler() {
+        public ObjectSampler<double[]> getSampler() {
             return sampler;
         }
 
@@ -227,8 +216,8 @@ public class TriangleSamplerBenchmark {
          * @param c The third vertex.
          * @return the sampler
          */
-        protected abstract Sampler createSampler(UniformRandomProvider rng,
-                                                 double[] a, double[] b, double[] c);
+        protected abstract ObjectSampler<double[]> createSampler(UniformRandomProvider rng,
+                                                                 double[] a, double[] b, double[] c);
     }
 
     /**
@@ -248,8 +237,8 @@ public class TriangleSamplerBenchmark {
 
         /** {@inheritDoc} */
         @Override
-        protected Sampler createSampler(final UniformRandomProvider rng,
-                                        final double[] a, final double[] b, final double[] c) {
+        protected ObjectSampler<double[]> createSampler(final UniformRandomProvider rng,
+                                                        final double[] a, final double[] b, final double[] c) {
             if (BASELINE.equals(type)) {
                 return () -> {
                     final double s = rng.nextDouble();
@@ -362,8 +351,8 @@ public class TriangleSamplerBenchmark {
 
         /** {@inheritDoc} */
         @Override
-        protected Sampler createSampler(final UniformRandomProvider rng,
-                                        final double[] a, final double[] b, final double[] c) {
+        protected ObjectSampler<double[]> createSampler(final UniformRandomProvider rng,
+                                                        final double[] a, final double[] b, final double[] c) {
             if (BASELINE.equals(type)) {
                 return () -> {
                     final double s = rng.nextDouble();
@@ -494,8 +483,8 @@ public class TriangleSamplerBenchmark {
 
         /** {@inheritDoc} */
         @Override
-        protected Sampler createSampler(final UniformRandomProvider rng,
-                                        final double[] a, final double[] b, final double[] c) {
+        protected ObjectSampler<double[]> createSampler(final UniformRandomProvider rng,
+                                                        final double[] a, final double[] b, final double[] c) {
             if (BASELINE.equals(type)) {
                 return () -> {
                     double s = rng.nextDouble();
@@ -614,7 +603,7 @@ public class TriangleSamplerBenchmark {
      * @param data Input data.
      */
     private static void runSampler(Blackhole bh, SamplerData data) {
-        final Sampler sampler = data.getSampler();
+        final ObjectSampler<double[]> sampler = data.getSampler();
         for (int i = data.getSize() - 1; i >= 0; i--) {
             bh.consume(sampler.sample());
         }
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/UnitBallSamplerBenchmark.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/UnitBallSamplerBenchmark.java
index 8fc30ff..281b5f4 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/UnitBallSamplerBenchmark.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/UnitBallSamplerBenchmark.java
@@ -18,6 +18,7 @@
 package org.apache.commons.rng.examples.jmh.sampling.shape;
 
 import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.sampling.ObjectSampler;
 import org.apache.commons.rng.sampling.distribution.ContinuousSampler;
 import org.apache.commons.rng.sampling.distribution.NormalizedGaussianSampler;
 import org.apache.commons.rng.sampling.distribution.ZigguratSampler;
@@ -64,21 +65,9 @@ public class UnitBallSamplerBenchmark {
     private static final long LOWER_53_BITS = -1L >>> 11;
 
     /**
-     * The sampler.
-     */
-    private interface Sampler {
-        /**
-         * Gets the next sample.
-         *
-         * @return the sample
-         */
-        double[] sample();
-    }
-
-    /**
      * Base class for a sampler using a provided source of randomness.
      */
-    private abstract static class BaseSampler implements Sampler {
+    private abstract static class BaseSampler implements ObjectSampler<double[]> {
         /** The source of randomness. */
         protected UniformRandomProvider rng;
 
@@ -100,7 +89,7 @@ public class UnitBallSamplerBenchmark {
     @State(Scope.Benchmark)
     public abstract static class SamplerData {
         /** The sampler. */
-        private Sampler sampler;
+        private ObjectSampler<double[]> sampler;
 
         /** The number of samples. */
         @Param({//"1",
@@ -121,7 +110,7 @@ public class UnitBallSamplerBenchmark {
          *
          * @return the sampler
          */
-        public Sampler getSampler() {
+        public ObjectSampler<double[]> getSampler() {
             return sampler;
         }
 
@@ -141,7 +130,7 @@ public class UnitBallSamplerBenchmark {
          * @param rng the source of randomness
          * @return the sampler
          */
-        protected abstract Sampler createSampler(UniformRandomProvider rng);
+        protected abstract ObjectSampler<double[]> createSampler(UniformRandomProvider rng);
     }
 
     /**
@@ -164,7 +153,7 @@ public class UnitBallSamplerBenchmark {
 
         /** {@inheritDoc} */
         @Override
-        protected Sampler createSampler(final UniformRandomProvider rng) {
+        protected ObjectSampler<double[]> createSampler(final UniformRandomProvider rng) {
             if (BASELINE.equals(type)) {
                 return () -> new double[] {0.5};
             } else if (SIGNED_DOUBLE.equals(type)) {
@@ -196,7 +185,7 @@ public class UnitBallSamplerBenchmark {
 
         /** {@inheritDoc} */
         @Override
-        protected Sampler createSampler(final UniformRandomProvider rng) {
+        protected ObjectSampler<double[]> createSampler(final UniformRandomProvider rng) {
             if (BASELINE.equals(type)) {
                 return () -> new double[] {0.5, 0};
             } else if (REJECTION.equals(type)) {
@@ -341,7 +330,7 @@ public class UnitBallSamplerBenchmark {
 
         /** {@inheritDoc} */
         @Override
-        protected Sampler createSampler(final UniformRandomProvider rng) {
+        protected ObjectSampler<double[]> createSampler(final UniformRandomProvider rng) {
             if (BASELINE.equals(type)) {
                 return () -> new double[] {0.5, 0, 0};
             } else if (REJECTION.equals(type)) {
@@ -506,9 +495,9 @@ public class UnitBallSamplerBenchmark {
 
         /** {@inheritDoc} */
         @Override
-        protected Sampler createSampler(final UniformRandomProvider rng) {
+        protected ObjectSampler<double[]> createSampler(final UniformRandomProvider rng) {
             if (BASELINE.equals(type)) {
-                return new Sampler() {
+                return new ObjectSampler<double[]>() {
                     private final int dim = dimension;
                     @Override
                     public double[] sample() {
@@ -745,7 +734,7 @@ public class UnitBallSamplerBenchmark {
      * @param data Input data.
      */
     private static void runSampler(Blackhole bh, SamplerData data) {
-        final Sampler sampler = data.getSampler();
+        final ObjectSampler<double[]> sampler = data.getSampler();
         for (int i = data.getSize() - 1; i >= 0; i--) {
             bh.consume(sampler.sample());
         }

[commons-rng] 06/12: Use java.util.function.DoubleUnaryOperator

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8b0059ccd744c43b9119a2bd31b581e8a55d0cdf
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Aug 13 19:40:25 2021 +0100

    Use java.util.function.DoubleUnaryOperator
    
    Return lambdas.
---
 .../rng/sampling/shape/UnitBallSamplerTest.java    | 110 +++------------------
 1 file changed, 16 insertions(+), 94 deletions(-)

diff --git a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/shape/UnitBallSamplerTest.java b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/shape/UnitBallSamplerTest.java
index 5a030c8..72b400b 100644
--- a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/shape/UnitBallSamplerTest.java
+++ b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/shape/UnitBallSamplerTest.java
@@ -17,7 +17,7 @@
 package org.apache.commons.rng.sampling.shape;
 
 import java.util.Arrays;
-
+import java.util.function.DoubleUnaryOperator;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -110,11 +110,11 @@ public class UnitBallSamplerTest {
         final int orthants = 1 << dimension;
 
         // Compute the radius for each layer to have the same volume.
-        final double volume = createVolumeFunction(dimension).apply(1);
+        final double volume = createVolumeFunction(dimension).applyAsDouble(1);
         final DoubleUnaryOperator radius = createRadiusFunction(dimension);
         final double[] r = new double[layers];
         for (int i = 1; i < layers; i++) {
-            r[i - 1] = radius.apply(volume * ((double) i / layers));
+            r[i - 1] = radius.applyAsDouble(volume * ((double) i / layers));
         }
         // The final radius should be 1.0. Any coordinates with a radius above 1
         // should fail so explicitly set the value as 1.
@@ -273,28 +273,12 @@ public class UnitBallSamplerTest {
             final DoubleUnaryOperator volume = createVolumeFunction(n);
             final DoubleUnaryOperator radius = createRadiusFunction(n);
             for (final double r : radii) {
-                Assert.assertEquals(r, radius.apply(volume.apply(r)), 1e-10);
+                Assert.assertEquals(r, radius.applyAsDouble(volume.applyAsDouble(r)), 1e-10);
             }
         }
     }
 
     /**
-     * Specify computation of a double-valued result for a given double.
-     *
-     * <p>This can be replaced with java.util.function.DoubleUnaryOperator when the source
-     * requires Java 1.8.
-     */
-    private interface DoubleUnaryOperator {
-        /**
-         * Compute the result.
-         *
-         * @param value the input value
-         * @return the result
-         */
-        double apply(double value);
-    }
-
-    /**
      * Creates a function to compute the volume of a ball of the given dimension
      * from the radius.
      *
@@ -303,53 +287,22 @@ public class UnitBallSamplerTest {
      * @see <a href="https://en.wikipedia.org/wiki/Volume_of_an_n-ball">Volume of an n-ball</a>
      */
     private static DoubleUnaryOperator createVolumeFunction(final int dimension) {
-        // This can be simplified using lambda functions when the source requires Java 1.8
         if (dimension == 1) {
-            return new DoubleUnaryOperator() {
-                @Override
-                public double apply(double r) {
-                    return r * 2;
-                }
-            };
+            return r -> r * 2;
         } else if (dimension == 2) {
-            return new DoubleUnaryOperator() {
-                @Override
-                public double apply(double r) {
-                    return Math.PI * r * r;
-                }
-            };
+            return r -> Math.PI * r * r;
         } else if (dimension == 3) {
             final double factor = 4 * Math.PI / 3;
-            return new DoubleUnaryOperator() {
-                @Override
-                public double apply(double r) {
-                    return factor * Math.pow(r, 3);
-                }
-            };
+            return r -> factor * Math.pow(r, 3);
         } else if (dimension == 4) {
             final double factor = Math.PI * Math.PI / 2;
-            return new DoubleUnaryOperator() {
-                @Override
-                public double apply(double r) {
-                    return factor * Math.pow(r, 4);
-                }
-            };
+            return r -> factor * Math.pow(r, 4);
         } else if (dimension == 5) {
             final double factor = 8 * Math.PI * Math.PI / 15;
-            return new DoubleUnaryOperator() {
-                @Override
-                public double apply(double r) {
-                    return factor * Math.pow(r, 5);
-                }
-            };
+            return r -> factor * Math.pow(r, 5);
         } else if (dimension == 6) {
             final double factor = Math.pow(Math.PI, 3) / 6;
-            return new DoubleUnaryOperator() {
-                @Override
-                public double apply(double r) {
-                    return factor * Math.pow(r, 6);
-                }
-            };
+            return r -> factor * Math.pow(r, 6);
         }
         throw new IllegalStateException("Unsupported dimension: " + dimension);
     }
@@ -363,53 +316,22 @@ public class UnitBallSamplerTest {
      * @see <a href="https://en.wikipedia.org/wiki/Volume_of_an_n-ball">Volume of an n-ball</a>
      */
     private static DoubleUnaryOperator createRadiusFunction(final int dimension) {
-        // This can be simplified using lambda functions when the source requires Java 1.8
         if (dimension == 1) {
-            return new DoubleUnaryOperator() {
-                @Override
-                public double apply(double v) {
-                    return v * 0.5;
-                }
-            };
+            return v -> v * 0.5;
         } else if (dimension == 2) {
-            return new DoubleUnaryOperator() {
-                @Override
-                public double apply(double v) {
-                    return Math.sqrt(v / Math.PI);
-                }
-            };
+            return v -> Math.sqrt(v / Math.PI);
         } else if (dimension == 3) {
             final double factor = 3.0 / (4 * Math.PI);
-            return new DoubleUnaryOperator() {
-                @Override
-                public double apply(double v) {
-                    return Math.cbrt(v * factor);
-                }
-            };
+            return v -> Math.cbrt(v * factor);
         } else if (dimension == 4) {
             final double factor = 2.0 / (Math.PI * Math.PI);
-            return new DoubleUnaryOperator() {
-                @Override
-                public double apply(double v) {
-                    return Math.pow(v * factor, 0.25);
-                }
-            };
+            return v -> Math.pow(v * factor, 0.25);
         } else if (dimension == 5) {
             final double factor = 15.0 / (8 * Math.PI * Math.PI);
-            return new DoubleUnaryOperator() {
-                @Override
-                public double apply(double v) {
-                    return Math.pow(v * factor, 0.2);
-                }
-            };
+            return v -> Math.pow(v * factor, 0.2);
         } else if (dimension == 6) {
             final double factor = 6.0 / Math.pow(Math.PI, 3);
-            return new DoubleUnaryOperator() {
-                @Override
-                public double apply(double v) {
-                    return Math.pow(v * factor, 1.0 / 6);
-                }
-            };
+            return v -> Math.pow(v * factor, 1.0 / 6);
         }
         throw new IllegalStateException("Unsupported dimension: " + dimension);
     }

[commons-rng] 07/12: Update minimum java version in documentation

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 87bb55f1d799a3d58a1b859c033c5a894aea08d3
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Aug 13 19:44:43 2021 +0100

    Update minimum java version in documentation
---
 src/site/apt/userguide/rng.apt | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/site/apt/userguide/rng.apt b/src/site/apt/userguide/rng.apt
index 76ab63a..bc28aa3 100644
--- a/src/site/apt/userguide/rng.apt
+++ b/src/site/apt/userguide/rng.apt
@@ -40,13 +40,13 @@
 
   The library is divided into modules:
 
-  * {{{../commons-rng-client-api/apidocs/org/apache/commons/rng/package-summary.html}Client API}} (requires Java 7)
+  * {{{../commons-rng-client-api/apidocs/org/apache/commons/rng/package-summary.html}Client API}} (requires Java 8)
 
   This module provides the
   {{{../commons-rng-client-api/apidocs/org/apache/commons/rng/RestorableUniformRandomProvider.html}interface}}
   to be passed as argument to a procedure that needs to access to a sequence of random numbers.
 
-  * {{{../commons-rng-core/apidocs/org/apache/commons/rng/core/package-summary.html}Core}} (requires Java 7)
+  * {{{../commons-rng-core/apidocs/org/apache/commons/rng/core/package-summary.html}Core}} (requires Java 8)
 
   This module contains the implementations of several generators of pseudo-random sequences of numbers.
   Code in this module is intended to be internal to this library and no user code should access it
@@ -56,12 +56,12 @@
   {{{../commons-rng-simple/apidocs/org/apache/commons/rng/simple/RandomSource.html}RandomSource}}
   factory.
 
-  * {{{../commons-rng-simple/apidocs/org/apache/commons/rng/simple/package-summary.html}Simple}} (requires Java 7)
+  * {{{../commons-rng-simple/apidocs/org/apache/commons/rng/simple/package-summary.html}Simple}} (requires Java 8)
 
   This module provides factory methods for creating instances of all the generators implemented
   in the <<<commons-rng-core>>> module.
 
-  * {{{../commons-rng-sampling/apidocs/org/apache/commons/rng/sampling/package-summary.html}Sampling}} (requires Java 7)
+  * {{{../commons-rng-sampling/apidocs/org/apache/commons/rng/sampling/package-summary.html}Sampling}} (requires Java 8)
 
   This module provides implementations that: generate a sequence of numbers according to some
   specified probability distribution; sample coordinates from geometric shapes; sample
@@ -77,7 +77,7 @@
 
   As of version 1.1, the following modules are provided:
 
-   ** <<<examples-jmh>>>: JMH benchmarking (requires Java 7)
+   ** <<<examples-jmh>>>: JMH benchmarking (requires Java 8)
 
    This module uses the {{{http://openjdk.java.net/projects/code-tools/jmh/}JMH micro-benchmark framework}}
    in order to assess the relative performance of the generators (see tables below).
@@ -97,7 +97,7 @@
    This module implements a dummy application that shows how to use the artefacts (produced
    from the maven modules described above) as Java modules ({{{https://en.wikipedia.org/wiki/Java_Platform_Module_System}JPMS}}).
 
-   ** <<<examples-quadrature>>>: Quadrature (requires Java 7)
+   ** <<<examples-quadrature>>>: Quadrature (requires Java 8)
 
    This module contains an application that estimates the number 𝞹 using quasi-Montecarlo integration.
 

[commons-rng] 10/12: Update description of java requirements in the user guide

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3a17ec34f7c3b7aaa5e94e7c94ecf28bc127a59f
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Aug 13 19:56:03 2021 +0100

    Update description of java requirements in the user guide
---
 src/site/apt/userguide/rng.apt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/site/apt/userguide/rng.apt b/src/site/apt/userguide/rng.apt
index bc28aa3..d5aab53 100644
--- a/src/site/apt/userguide/rng.apt
+++ b/src/site/apt/userguide/rng.apt
@@ -981,17 +981,19 @@ double[] coordinate = sampler.sample();
 *----------*---------------+
 || Example Module || Description ||
 *----------*---------------+
-| Stress | Application for calling external tools that perform stringent uniformity tests (requires Java 8+). This application is used to generate results in the {{{a5._Quality}Quality}} section. |
+| Stress | Application for calling external tools that perform stringent uniformity tests. This application is used to generate results in the {{{a5._Quality}Quality}} section. |
 *----------*---------------+
 | Sampling | Application producing output from distribution samplers to create an approximate probability density function (PDF) as shown {{{./dist_density_approx.html}here}}. |
 *----------*---------------+
 | Quadrature | Application for computing numerical quadrature by Monte-Carlo (random) integration. |
 *----------*---------------+
-| JMH | Benchmarks that assess the performance of the generators using the Java Microbenchmark Harness (requires Java 8+). This application is used to generate results in the {{{a4._Performance}Performance}} section. |
+| JMH | Benchmarks that assess the performance of the generators using the Java Microbenchmark Harness. This application is used to generate results in the {{{a4._Performance}Performance}} section. |
 *----------*---------------+
 | JPMS | Example JPMS application using all the JPMS modules of Commons RNG (requires Java 11+). |
 *----------*---------------+
 
+  The examples require Java 8+ unless specifed as requiring a higher version.
+
   The examples can be built using profiles in the relevant module. For example to build the
   JMH benchmarks application and show the help information:
 

[commons-rng] 11/12: Use lambdas

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d7be418f2e2e5ff4e7913152e965a6f52d7a0ff1
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Aug 13 20:20:20 2021 +0100

    Use lambdas
---
 .../jmh/sampling/UnitSphereSamplerBenchmark.java   |  64 +++------
 .../EnumeratedDistributionSamplersPerformance.java |  63 ++-------
 .../PoissonSamplerCachePerformance.java            |  21 +--
 .../distribution/PoissonSamplersPerformance.java   |  58 ++------
 .../distribution/StableSamplerPerformance.java     | 154 +++++++--------------
 .../distribution/ZigguratSamplerPerformance.java   |  32 ++---
 .../shape/TetrahedronSamplerBenchmark.java         |  13 +-
 .../sampling/shape/TriangleSamplerBenchmark.java   | 104 ++++++--------
 .../sampling/shape/UnitBallSamplerBenchmark.java   |  59 ++------
 9 files changed, 155 insertions(+), 413 deletions(-)

diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/UnitSphereSamplerBenchmark.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/UnitSphereSamplerBenchmark.java
index ed93ca0..154d281 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/UnitSphereSamplerBenchmark.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/UnitSphereSamplerBenchmark.java
@@ -144,43 +144,28 @@ public class UnitSphereSamplerBenchmark {
         @Override
         protected Sampler createSampler(final UniformRandomProvider rng) {
             if (BASELINE.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        return new double[] {1.0};
-                    }
+                return () -> {
+                    return new double[] {1.0};
                 };
             } else if (SIGNED_DOUBLE.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        // (1 - 0) or (1 - 2)
-                        // Use the sign bit
-                        return new double[] {1.0 - ((rng.nextInt() >>> 30) & 0x2)};
-                    }
+                return () -> {
+                    // (1 - 0) or (1 - 2)
+                    // Use the sign bit
+                    return new double[] {1.0 - ((rng.nextInt() >>> 30) & 0x2)};
                 };
             } else if (MASKED_INT.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        // Shift the sign bit and combine with the bits for a double of 1.0
-                        return new double[] {Double.longBitsToDouble(ONE | ((rng.nextInt() & SIGN_BIT) << 32))};
-                    }
+                return () -> {
+                    // Shift the sign bit and combine with the bits for a double of 1.0
+                    return new double[] {Double.longBitsToDouble(ONE | ((rng.nextInt() & SIGN_BIT) << 32))};
                 };
             } else if (MASKED_LONG.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        // Combine the sign bit with the bits for a double of 1.0
-                        return new double[] {Double.longBitsToDouble(ONE | (rng.nextLong() & Long.MIN_VALUE))};
-                    }
+                return () -> {
+                    // Combine the sign bit with the bits for a double of 1.0
+                    return new double[] {Double.longBitsToDouble(ONE | (rng.nextLong() & Long.MIN_VALUE))};
                 };
             } else if (BOOLEAN.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        return new double[] {rng.nextBoolean() ? -1.0 : 1.0};
-                    }
+                return () -> {
+                    return new double[] {rng.nextBoolean() ? -1.0 : 1.0};
                 };
             } else if (ARRAY.equals(type)) {
                 return new ArrayBasedUnitSphereSampler(1, rng);
@@ -202,11 +187,8 @@ public class UnitSphereSamplerBenchmark {
         @Override
         protected Sampler createSampler(final UniformRandomProvider rng) {
             if (BASELINE.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        return new double[] {1.0, 0.0};
-                    }
+                return () -> {
+                    return new double[] {1.0, 0.0};
                 };
             } else if (ARRAY.equals(type)) {
                 return new ArrayBasedUnitSphereSampler(2, rng);
@@ -260,11 +242,8 @@ public class UnitSphereSamplerBenchmark {
         @Override
         protected Sampler createSampler(final UniformRandomProvider rng) {
             if (BASELINE.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        return new double[] {1.0, 0.0, 0.0};
-                    }
+                return () -> {
+                    return new double[] {1.0, 0.0, 0.0};
                 };
             } else if (ARRAY.equals(type)) {
                 return new ArrayBasedUnitSphereSampler(3, rng);
@@ -319,11 +298,8 @@ public class UnitSphereSamplerBenchmark {
         @Override
         protected Sampler createSampler(final UniformRandomProvider rng) {
             if (BASELINE.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        return new double[] {1.0, 0.0, 0.0, 0.0};
-                    }
+                return () -> {
+                    return new double[] {1.0, 0.0, 0.0, 0.0};
                 };
             } else if (ARRAY.equals(type)) {
                 return new ArrayBasedUnitSphereSampler(4, rng);
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/EnumeratedDistributionSamplersPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/EnumeratedDistributionSamplersPerformance.java
index 3307048..2828f44 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/EnumeratedDistributionSamplersPerformance.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/EnumeratedDistributionSamplersPerformance.java
@@ -182,68 +182,23 @@ public class EnumeratedDistributionSamplersPerformance {
             final double[] probabilities) {
             // This would benefit from Java 8 lambda functions
             if ("BinarySearchDiscreteSampler".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        return new BinarySearchDiscreteSampler(rng, probabilities);
-                    }
-                };
+                factory = () -> new BinarySearchDiscreteSampler(rng, probabilities);
             } else if ("AliasMethodDiscreteSampler".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        return AliasMethodDiscreteSampler.of(rng, probabilities);
-                    }
-                };
+                factory = () -> AliasMethodDiscreteSampler.of(rng, probabilities);
             } else if ("AliasMethodDiscreteSamplerNoPad".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        return AliasMethodDiscreteSampler.of(rng, probabilities, -1);
-                    }
-                };
+                factory = () -> AliasMethodDiscreteSampler.of(rng, probabilities, -1);
             } else if ("AliasMethodDiscreteSamplerAlpha1".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        return AliasMethodDiscreteSampler.of(rng, probabilities, 1);
-                    }
-                };
+                factory = () -> AliasMethodDiscreteSampler.of(rng, probabilities, 1);
             } else if ("AliasMethodDiscreteSamplerAlpha2".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        return AliasMethodDiscreteSampler.of(rng, probabilities, 2);
-                    }
-                };
+                factory = () -> AliasMethodDiscreteSampler.of(rng, probabilities, 2);
             } else if ("GuideTableDiscreteSampler".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        return GuideTableDiscreteSampler.of(rng, probabilities);
-                    }
-                };
+                factory = () -> GuideTableDiscreteSampler.of(rng, probabilities);
             } else if ("GuideTableDiscreteSamplerAlpha2".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        return GuideTableDiscreteSampler.of(rng, probabilities, 2);
-                    }
-                };
+                factory = () -> GuideTableDiscreteSampler.of(rng, probabilities, 2);
             } else if ("GuideTableDiscreteSamplerAlpha8".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        return GuideTableDiscreteSampler.of(rng, probabilities, 8);
-                    }
-                };
+                factory = () -> GuideTableDiscreteSampler.of(rng, probabilities, 8);
             } else if ("MarsagliaTsangWangDiscreteSampler".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        return MarsagliaTsangWangDiscreteSampler.Enumerated.of(rng, probabilities);
-                    }
-                };
+                factory = () -> MarsagliaTsangWangDiscreteSampler.Enumerated.of(rng, probabilities);
             } else {
                 throw new IllegalStateException();
             }
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplerCachePerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplerCachePerformance.java
index 6a80639..4495374 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplerCachePerformance.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplerCachePerformance.java
@@ -307,12 +307,7 @@ public class PoissonSamplerCachePerformance {
                                   MeanRange range,
                                   Blackhole bh) {
         final UniformRandomProvider r = sources.getGenerator();
-        final PoissonSamplerFactory factory = new PoissonSamplerFactory() {
-            @Override
-            public DiscreteSampler createPoissonSampler(double mean) {
-                return PoissonSampler.of(r, mean);
-            }
-        };
+        final PoissonSamplerFactory factory = mean -> PoissonSampler.of(r, mean);
         runSample(factory, range, bh);
     }
 
@@ -327,12 +322,7 @@ public class PoissonSamplerCachePerformance {
                                                 Blackhole bh) {
         final UniformRandomProvider r = sources.getGenerator();
         final PoissonSamplerCache cache = new PoissonSamplerCache(0, 0);
-        final PoissonSamplerFactory factory = new PoissonSamplerFactory() {
-            @Override
-            public DiscreteSampler createPoissonSampler(double mean) {
-                return cache.createSharedStateSampler(r, mean);
-            }
-        };
+        final PoissonSamplerFactory factory = mean -> cache.createSharedStateSampler(r, mean);
         runSample(factory, range, bh);
     }
 
@@ -348,12 +338,7 @@ public class PoissonSamplerCachePerformance {
         final UniformRandomProvider r = sources.getGenerator();
         final PoissonSamplerCache cache = new PoissonSamplerCache(
                 range.getMin(), range.getMax());
-        final PoissonSamplerFactory factory = new PoissonSamplerFactory() {
-            @Override
-            public DiscreteSampler createPoissonSampler(double mean) {
-                return cache.createSharedStateSampler(r, mean);
-            }
-        };
+        final PoissonSamplerFactory factory = mean -> cache.createSharedStateSampler(r, mean);
         runSample(factory, range, bh);
     }
 }
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplersPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplersPerformance.java
index f167a4d..8537431 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplersPerformance.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/PoissonSamplersPerformance.java
@@ -177,63 +177,21 @@ public class PoissonSamplersPerformance {
 
             // This would benefit from Java 8 Supplier<DiscreteSampler> lambda function
             if ("SmallMeanPoissonSampler".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        return SmallMeanPoissonSampler.of(generator, mean);
-                    }
-                };
+                factory = () -> SmallMeanPoissonSampler.of(generator, mean);
             } else if ("KempSmallMeanPoissonSampler".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        return KempSmallMeanPoissonSampler.of(generator, mean);
-                    }
-                };
+                factory = () -> KempSmallMeanPoissonSampler.of(generator, mean);
             } else if ("BoundedKempSmallMeanPoissonSampler".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        return new BoundedKempSmallMeanPoissonSampler(generator, mean);
-                    }
-                };
+                factory = () -> new BoundedKempSmallMeanPoissonSampler(generator, mean);
             } else if ("KempSmallMeanPoissonSamplerP50".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        return new KempSmallMeanPoissonSamplerP50(generator, mean);
-                    }
-                };
+                factory = () -> new KempSmallMeanPoissonSamplerP50(generator, mean);
             } else if ("KempSmallMeanPoissonSamplerBinarySearch".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        return new KempSmallMeanPoissonSamplerBinarySearch(generator, mean);
-                    }
-                };
+                factory = () -> new KempSmallMeanPoissonSamplerBinarySearch(generator, mean);
             } else if ("KempSmallMeanPoissonSamplerGuideTable".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        return new KempSmallMeanPoissonSamplerGuideTable(generator, mean);
-                    }
-                };
+                factory = () -> new KempSmallMeanPoissonSamplerGuideTable(generator, mean);
             } else if ("LargeMeanPoissonSampler".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        // Note this is not valid when mean < 1
-                        return LargeMeanPoissonSampler.of(generator, mean);
-                    }
-                };
+                factory = () -> LargeMeanPoissonSampler.of(generator, mean);
             } else if ("TinyMeanPoissonSampler".equals(samplerType)) {
-                factory = new DiscreteSamplerFactory() {
-                    @Override
-                    public DiscreteSampler create() {
-                        // Note this is only valid when mean < -Math.exp(0x1p-32) == 22.18
-                        return new TinyMeanPoissonSampler(generator, mean);
-                    }
-                };
+                factory = () -> new TinyMeanPoissonSampler(generator, mean);
             }
             sampler = factory.create();
         }
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/StableSamplerPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/StableSamplerPerformance.java
index 22c1328..d8800a5 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/StableSamplerPerformance.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/StableSamplerPerformance.java
@@ -681,23 +681,15 @@ public class StableSamplerPerformance {
         public void setup() {
             final UniformRandomProvider rng = getRNG();
             if (BASELINE.equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        return rng.nextDouble();
-                    }
-                };
+                sampler = rng::nextDouble;
             } else if ("nextDoubleNot0".equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        // Sample the 2^53 dyadic rationals in [0, 1) with zero excluded
-                        double x;
-                        do {
-                            x = rng.nextDouble();
-                        } while (x == 0);
-                        return x - 0.5;
-                    }
+                sampler = () -> {
+                    // Sample the 2^53 dyadic rationals in [0, 1) with zero excluded
+                    double x;
+                    do {
+                        x = rng.nextDouble();
+                    } while (x == 0);
+                    return x - 0.5;
                 };
             } else if ("nextDoubleNot0Recurse".equals(method)) {
                 sampler = new ContinuousSampler() {
@@ -714,34 +706,25 @@ public class StableSamplerPerformance {
                     }
                 };
             } else if ("nextLongNot0".equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        // Sample the 2^53 dyadic rationals in [0, 1) with zero excluded
-                        long x;
-                        do {
-                            x = rng.nextLong() >>> 11;
-                        } while (x == 0);
-                        return x * 0x1.0p-53 - 0.5;
-                    }
+                sampler = () -> {
+                    // Sample the 2^53 dyadic rationals in [0, 1) with zero excluded
+                    long x;
+                    do {
+                        x = rng.nextLong() >>> 11;
+                    } while (x == 0);
+                    return x * 0x1.0p-53 - 0.5;
                 };
             } else if ("nextDoubleShifted".equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        // Sample the 2^52 dyadic rationals in [0, 1) and shift by 2^-53.
-                        // No infinite loop but the deviate loses 1 bit of randomness.
-                        return 0x1.0p-53 + (rng.nextLong() >>> 12) * 0x1.0p-52 - 0.5;
-                    }
+                sampler = () -> {
+                    // Sample the 2^52 dyadic rationals in [0, 1) and shift by 2^-53.
+                    // No infinite loop but the deviate loses 1 bit of randomness.
+                    return 0x1.0p-53 + (rng.nextLong() >>> 12) * 0x1.0p-52 - 0.5;
                 };
             } else if ("nextLongShifted".equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        // Sample the 2^53 dyadic rationals in [0, 1) but set the lowest
-                        // bit. This result in 2^52 dyadic rationals in (0, 1) to avoid 0.
-                        return ((rng.nextLong() >>> 11) | 0x1L) * 0x1.0p-53 - 0.5;
-                    }
+                sampler = () -> {
+                    // Sample the 2^53 dyadic rationals in [0, 1) but set the lowest
+                    // bit. This result in 2^52 dyadic rationals in (0, 1) to avoid 0.
+                    return ((rng.nextLong() >>> 11) | 0x1L) * 0x1.0p-53 - 0.5;
                 };
             } else if ("signedShift".equals(method)) {
                 sampler = new ContinuousSampler() {
@@ -832,53 +815,35 @@ public class StableSamplerPerformance {
         public void setup() {
             final UniformRandomProvider rng = getRNG();
             if (BASELINE.equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        // A value in [-pi/4, pi/4]
-                        return PI_2 * (rng.nextDouble() - 0.5);
-                    }
+                sampler = () -> {
+                    // A value in [-pi/4, pi/4]
+                    return PI_2 * (rng.nextDouble() - 0.5);
                 };
             } else if ("tan".equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        final double x = PI_2 * (rng.nextDouble() - 0.5);
-                        // Require tan(0) / 0 = 1 and not NaN
-                        return x == 0 ? 1.0 : Math.tan(x) / x;
-                    }
+                sampler = () -> {
+                    final double x = PI_2 * (rng.nextDouble() - 0.5);
+                    // Require tan(0) / 0 = 1 and not NaN
+                    return x == 0 ? 1.0 : Math.tan(x) / x;
                 };
             } else if ("tan4283".equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        final double x = PI_2 * (rng.nextDouble() - 0.5);
-                        return x * tan4283(x);
-                    }
+                sampler = () -> {
+                    final double x = PI_2 * (rng.nextDouble() - 0.5);
+                    return x * tan4283(x);
                 };
             } else if ("tan4288".equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        final double x = PI_2 * (rng.nextDouble() - 0.5);
-                        return x * tan4288(x);
-                    }
+                sampler = () -> {
+                    final double x = PI_2 * (rng.nextDouble() - 0.5);
+                    return x * tan4288(x);
                 };
             } else if ("tan4288b".equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        final double x = PI_2 * (rng.nextDouble() - 0.5);
-                        return x * tan4288b(x);
-                    }
+                sampler = () -> {
+                    final double x = PI_2 * (rng.nextDouble() - 0.5);
+                    return x * tan4288b(x);
                 };
             } else if ("tan4288c".equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        final double x = PI_2 * (rng.nextDouble() - 0.5);
-                        return x * tan4288c(x);
-                    }
+                sampler = () -> {
+                    final double x = PI_2 * (rng.nextDouble() - 0.5);
+                    return x * tan4288c(x);
                 };
             } else {
                 throw new IllegalStateException("Unknown tan method: " + method);
@@ -1104,40 +1069,15 @@ public class StableSamplerPerformance {
             final double s = scale;
             final UniformRandomProvider rng = getRNG();
             if (BASELINE.equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        return s * (rng.nextDouble() - 0.5);
-                    }
-                };
+                sampler = () -> s * (rng.nextDouble() - 0.5);
             } else if ("expm1".equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        return expm1(s * (rng.nextDouble() - 0.5));
-                    }
-                };
+                sampler = () -> expm1(s * (rng.nextDouble() - 0.5));
             } else if ("expm1b".equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        return expm1b(s * (rng.nextDouble() - 0.5));
-                    }
-                };
+                sampler = () -> expm1b(s * (rng.nextDouble() - 0.5));
             } else if ("exp".equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        return exp(s * (rng.nextDouble() - 0.5));
-                    }
-                };
+                sampler = () -> exp(s * (rng.nextDouble() - 0.5));
             } else if ("hybrid".equals(method)) {
-                sampler = new ContinuousSampler() {
-                    @Override
-                    public double sample() {
-                        return hybrid(s * (rng.nextDouble() - 0.5));
-                    }
-                };
+                sampler = () -> hybrid(s * (rng.nextDouble() - 0.5));
             } else {
                 throw new IllegalStateException("Unknown d2 method: " + method);
             }
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ZigguratSamplerPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ZigguratSamplerPerformance.java
index c1c5309..59a845a 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ZigguratSamplerPerformance.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ZigguratSamplerPerformance.java
@@ -133,20 +133,14 @@ public class ZigguratSamplerPerformance {
             // Use a fast generator
             final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_128_PP.create();
             if ("CastMask".equals(method)) {
-                sampler = new DiscreteSampler() {
-                    @Override
-                    public int sample() {
-                        final long x = rng.nextLong();
-                        return ((int) x) & 0xff;
-                    }
+                sampler = () -> {
+                    final long x = rng.nextLong();
+                    return ((int) x) & 0xff;
                 };
             } else if ("MaskCast".equals(method)) {
-                sampler = new DiscreteSampler() {
-                    @Override
-                    public int sample() {
-                        final long x = rng.nextLong();
-                        return (int) (x & 0xff);
-                    }
+                sampler = () -> {
+                    final long x = rng.nextLong();
+                    return (int) (x & 0xff);
                 };
             } else {
                 throwIllegalStateException(method);
@@ -189,19 +183,9 @@ public class ZigguratSamplerPerformance {
             // Use a fast generator
             final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_128_PP.create();
             if ("Mask".equals(method)) {
-                sampler = new LongSampler() {
-                    @Override
-                    public long sample() {
-                        return rng.nextLong() & Long.MAX_VALUE;
-                    }
-                };
+                sampler = () -> rng.nextLong() & Long.MAX_VALUE;
             } else if ("Shift".equals(method)) {
-                sampler = new LongSampler() {
-                    @Override
-                    public long sample() {
-                        return rng.nextLong() >>> 1;
-                    }
-                };
+                sampler = () -> rng.nextLong() >>> 1;
             } else {
                 throwIllegalStateException(method);
             }
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TetrahedronSamplerBenchmark.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TetrahedronSamplerBenchmark.java
index 0340ed4..5a5f858 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TetrahedronSamplerBenchmark.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TetrahedronSamplerBenchmark.java
@@ -452,14 +452,11 @@ public class TetrahedronSamplerBenchmark {
         private Sampler createSampler(final UniformRandomProvider rng,
                                       double[] a, double[] b, double[] c, double[] d) {
             if (BASELINE.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        final double s = rng.nextDouble();
-                        final double t = rng.nextDouble();
-                        final double u = rng.nextDouble();
-                        return new double[] {s, t, u};
-                    }
+                return () -> {
+                    final double s = rng.nextDouble();
+                    final double t = rng.nextDouble();
+                    final double u = rng.nextDouble();
+                    return new double[] {s, t, u};
                 };
             } else if (ARRAY.equals(type)) {
                 return new ArrayTetrahedronSampler(rng, a, b, c, d);
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TriangleSamplerBenchmark.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TriangleSamplerBenchmark.java
index 2997c96..67632e9 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TriangleSamplerBenchmark.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/TriangleSamplerBenchmark.java
@@ -251,25 +251,19 @@ public class TriangleSamplerBenchmark {
         protected Sampler createSampler(final UniformRandomProvider rng,
                                         final double[] a, final double[] b, final double[] c) {
             if (BASELINE.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        final double s = rng.nextDouble();
-                        final double t = rng.nextDouble();
-                        return new double[] {s, t};
-                    }
+                return () -> {
+                    final double s = rng.nextDouble();
+                    final double t = rng.nextDouble();
+                    return new double[] {s, t};
                 };
             } else if (BASELINE_IF.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        final double s = rng.nextDouble();
-                        final double t = rng.nextDouble();
-                        if (s + t > 1) {
-                            return new double[] {s, t};
-                        }
-                        return new double[] {t, s};
+                return () -> {
+                    final double s = rng.nextDouble();
+                    final double t = rng.nextDouble();
+                    if (s + t > 1) {
+                        return new double[] {s, t};
                     }
+                    return new double[] {t, s};
                 };
             } else if (VECTORS.equals(type)) {
                 return new VectorTriangleSampler2D(rng, a, b, c);
@@ -371,25 +365,19 @@ public class TriangleSamplerBenchmark {
         protected Sampler createSampler(final UniformRandomProvider rng,
                                         final double[] a, final double[] b, final double[] c) {
             if (BASELINE.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        final double s = rng.nextDouble();
-                        final double t = rng.nextDouble();
-                        return new double[] {s, t, s};
-                    }
+                return () -> {
+                    final double s = rng.nextDouble();
+                    final double t = rng.nextDouble();
+                    return new double[] {s, t, s};
                 };
             } else if (BASELINE_IF.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        final double s = rng.nextDouble();
-                        final double t = rng.nextDouble();
-                        if (s + t > 1) {
-                            return new double[] {s, t, s};
-                        }
-                        return new double[] {t, s, t};
+                return () -> {
+                    final double s = rng.nextDouble();
+                    final double t = rng.nextDouble();
+                    if (s + t > 1) {
+                        return new double[] {s, t, s};
                     }
+                    return new double[] {t, s, t};
                 };
             } else if (VECTORS.equals(type)) {
                 return new VectorTriangleSampler3D(rng, a, b, c);
@@ -509,42 +497,36 @@ public class TriangleSamplerBenchmark {
         protected Sampler createSampler(final UniformRandomProvider rng,
                                         final double[] a, final double[] b, final double[] c) {
             if (BASELINE.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        double s = rng.nextDouble();
-                        double t = rng.nextDouble();
-                        final double[] x = new double[a.length];
-                        for (int i = 0; i < x.length; i++) {
-                            x[i] = s;
-                            s = t;
-                            t = x[i];
-                        }
-                        return x;
+                return () -> {
+                    double s = rng.nextDouble();
+                    double t = rng.nextDouble();
+                    final double[] x = new double[a.length];
+                    for (int i = 0; i < x.length; i++) {
+                        x[i] = s;
+                        s = t;
+                        t = x[i];
                     }
+                    return x;
                 };
             } else if (BASELINE_IF.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        double s = rng.nextDouble();
-                        double t = rng.nextDouble();
-                        final double[] x = new double[a.length];
-                        if (s + t > 1) {
-                            for (int i = 0; i < x.length; i++) {
-                                x[i] = t;
-                                t = s;
-                                s = x[i];
-                            }
-                            return x;
-                        }
+                return () -> {
+                    double s = rng.nextDouble();
+                    double t = rng.nextDouble();
+                    final double[] x = new double[a.length];
+                    if (s + t > 1) {
                         for (int i = 0; i < x.length; i++) {
-                            x[i] = s;
-                            s = t;
-                            t = x[i];
+                            x[i] = t;
+                            t = s;
+                            s = x[i];
                         }
                         return x;
                     }
+                    for (int i = 0; i < x.length; i++) {
+                        x[i] = s;
+                        s = t;
+                        t = x[i];
+                    }
+                    return x;
                 };
             } else if (VECTORS.equals(type)) {
                 return new VectorTriangleSamplerND(rng, a, b, c);
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/UnitBallSamplerBenchmark.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/UnitBallSamplerBenchmark.java
index 04c098d..8fc30ff 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/UnitBallSamplerBenchmark.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/shape/UnitBallSamplerBenchmark.java
@@ -166,45 +166,20 @@ public class UnitBallSamplerBenchmark {
         @Override
         protected Sampler createSampler(final UniformRandomProvider rng) {
             if (BASELINE.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        return new double[] {0.5};
-                    }
-                };
+                return () -> new double[] {0.5};
             } else if (SIGNED_DOUBLE.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        // Sample [-1, 1) uniformly
-                        return new double[] {makeSignedDouble(rng.nextLong())};
-                    }
-                };
+                // Sample [-1, 1) uniformly
+                return () -> new double[] {makeSignedDouble(rng.nextLong())};
             } else if (SIGNED_DOUBLE2.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        // Sample [-1, 1) uniformly
-                        return new double[] {makeSignedDouble2(rng.nextLong())};
-                    }
-                };
+                // Sample [-1, 1) uniformly
+                return () -> new double[] {makeSignedDouble2(rng.nextLong())};
             } else if (TWO_DOUBLES.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        // Sample [-1, 1) excluding -0.0 but also missing the final 1.0 - 2^-53.
-                        // The 1.0 could be adjusted to 1.0 - 2^-53 to create the interval (-1, 1).
-                        return new double[] {rng.nextDouble() + rng.nextDouble() - 1.0};
-                    }
-                };
+                // Sample [-1, 1) excluding -0.0 but also missing the final 1.0 - 2^-53.
+                // The 1.0 could be adjusted to 1.0 - 2^-53 to create the interval (-1, 1).
+                return () -> new double[] {rng.nextDouble() + rng.nextDouble() - 1.0};
             } else if (BOOLEAN_DOUBLE.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        // This will sample (-1, 1) including -0.0 and 0.0
-                        return new double[] {rng.nextBoolean() ? -rng.nextDouble() : rng.nextDouble()};
-                    }
-                };
+                // This will sample (-1, 1) including -0.0 and 0.0
+                return () -> new double[] {rng.nextBoolean() ? -rng.nextDouble() : rng.nextDouble()};
             }
             throw new IllegalStateException(UNKNOWN_SAMPLER + type);
         }
@@ -223,12 +198,7 @@ public class UnitBallSamplerBenchmark {
         @Override
         protected Sampler createSampler(final UniformRandomProvider rng) {
             if (BASELINE.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        return new double[] {0.5, 0};
-                    }
-                };
+                return () -> new double[] {0.5, 0};
             } else if (REJECTION.equals(type)) {
                 return new RejectionSampler(rng);
             } else if (DISK_POINT.equals(type)) {
@@ -373,12 +343,7 @@ public class UnitBallSamplerBenchmark {
         @Override
         protected Sampler createSampler(final UniformRandomProvider rng) {
             if (BASELINE.equals(type)) {
-                return new Sampler() {
-                    @Override
-                    public double[] sample() {
-                        return new double[] {0.5, 0, 0};
-                    }
-                };
+                return () -> new double[] {0.5, 0, 0};
             } else if (REJECTION.equals(type)) {
                 return new RejectionSampler(rng);
             } else if (BALL_POINT.equals(type)) {

[commons-rng] 09/12: Update examples/release profiles to require java 11

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e98e5102b26db23ec79a4fae3adc0b961ebe4319
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Aug 13 19:47:05 2021 +0100

    Update examples/release profiles to require java 11
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 374ac64..4f7b9bf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -107,7 +107,7 @@
     <module>commons-rng-simple</module>
     <module>commons-rng-sampling</module>
     <!--
-        The examples are built only upon explicit request (requires Java 1.7+).
+        The examples are built only upon explicit request (requires Java 11).
         See profiles: "commons-rng-examples"; "release"
     -->
   </modules>

[commons-rng] 01/12: RNG-162: Update Java from 1.7 to 1.8

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c04f9da1f2e537d6afd93afbc2ede8a3d65d2262
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Aug 13 19:04:16 2021 +0100

    RNG-162: Update Java from 1.7 to 1.8
---
 commons-rng-examples/examples-sampling/pom.xml | 3 ---
 commons-rng-examples/examples-stress/pom.xml   | 3 ---
 pom.xml                                        | 6 +++---
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/commons-rng-examples/examples-sampling/pom.xml b/commons-rng-examples/examples-sampling/pom.xml
index 844a698..a34d639 100644
--- a/commons-rng-examples/examples-sampling/pom.xml
+++ b/commons-rng-examples/examples-sampling/pom.xml
@@ -33,9 +33,6 @@
   Code in this module is not part of the public API.</description>
 
   <properties>
-    <maven.compiler.source>1.8</maven.compiler.source>
-    <maven.compiler.target>1.8</maven.compiler.target>
-
     <!-- OSGi -->
     <commons.osgi.symbolicName>org.apache.commons.rng.examples.sampling</commons.osgi.symbolicName>
     <commons.osgi.export>org.apache.commons.rng.examples.sampling</commons.osgi.export>
diff --git a/commons-rng-examples/examples-stress/pom.xml b/commons-rng-examples/examples-stress/pom.xml
index 14d2315..e8b1af4 100644
--- a/commons-rng-examples/examples-stress/pom.xml
+++ b/commons-rng-examples/examples-stress/pom.xml
@@ -33,9 +33,6 @@
   Code in this module is not part of the public API.</description>
 
   <properties>
-    <maven.compiler.source>1.8</maven.compiler.source>
-    <maven.compiler.target>1.8</maven.compiler.target>
-
     <!-- OSGi -->
     <commons.osgi.symbolicName>org.apache.commons.rng.examples.stress</commons.osgi.symbolicName>
     <commons.osgi.export>org.apache.commons.rng.examples.stress</commons.osgi.export>
diff --git a/pom.xml b/pom.xml
index 47b009b..cd2b217 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,14 +45,14 @@
     <commons.release.version>1.3</commons.release.version>
     <commons.bc.version>${commons.release.version}</commons.bc.version>
     <commons.rc.version>RC1</commons.rc.version>
-    <commons.release.desc>(requires Java 6+)</commons.release.desc>
+    <commons.release.desc>(requires Java 8+)</commons.release.desc>
     <commons.binary.suffix>-bin</commons.binary.suffix>
 
     <commons.jira.id>RNG</commons.jira.id>
     <commons.jira.pid>12320623</commons.jira.pid>
     <commons.encoding>UTF-8</commons.encoding>
-    <maven.compiler.source>1.7</maven.compiler.source>
-    <maven.compiler.target>1.7</maven.compiler.target>
+    <maven.compiler.source>1.8</maven.compiler.source>
+    <maven.compiler.target>1.8</maven.compiler.target>
     <rng.clirr.version>2.8</rng.clirr.version>
     <rng.pmd.version>3.14.0</rng.pmd.version>
     <rng.pmd.dep.version>6.37.0</rng.pmd.dep.version>

[commons-rng] 02/12: Move Java 8 profile plugins to the main pom

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 54bf1607ded7e5c8696bce516f0fe6921056951b
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Aug 13 19:08:07 2021 +0100

    Move Java 8 profile plugins to the main pom
---
 pom.xml | 206 ++++++++++++++++++++++++++--------------------------------------
 1 file changed, 84 insertions(+), 122 deletions(-)

diff --git a/pom.xml b/pom.xml
index cd2b217..9ebd193 100644
--- a/pom.xml
+++ b/pom.xml
@@ -89,10 +89,10 @@
         Temporary workaround?
     -->
     <commons.release.name>commons-rng-${project.version}</commons.release.name>
-    <!-- Java8+ requires additional Javadoc qualifier for MathJax (default to empty). -->
-    <allowscript.javadoc.qualifier />
-    <!-- Invalid flag for old javadoc versions (default to empty). -->
-    <doclint.javadoc.qualifier />
+    <!-- MathJax script inclusion requires additional Javadoc qualifier for Java8 as of 8u121 -->
+    <allowscript.javadoc.qualifier>--allow-script-in-comments</allowscript.javadoc.qualifier>
+    <!-- Check for all javadoc errors -->
+    <doclint.javadoc.qualifier>-Xdoclint:all</doclint.javadoc.qualifier>
 
     <!-- Workaround to avoid the SVN site checkout in all modules.
          This flag should be deactivated by child modules. -->
@@ -213,8 +213,56 @@
           </ignorePathsToDelete>
         </configuration>
       </plugin>
-      <!-- spotbugs-maven-plugin runs in JDK 8+ profile so not included here -->
-      <!-- maven-checkstyle-plugin runs in JDK 8+ profile so not included here -->
+      <plugin>
+        <groupId>com.github.spotbugs</groupId>
+        <artifactId>spotbugs-maven-plugin</artifactId>
+        <version>${commons.spotbugs.version}</version>
+        <configuration>
+          <threshold>Normal</threshold>
+          <effort>Default</effort>
+          <excludeFilterFile>${rng.parent.dir}/src/main/resources/spotbugs/spotbugs-exclude-filter.xml</excludeFilterFile>
+        </configuration>
+        <executions>
+          <execution>
+            <phase>verify</phase>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <version>${rng.checkstyle.version}</version>
+        <dependencies>
+          <dependency>
+            <groupId>com.puppycrawl.tools</groupId>
+            <artifactId>checkstyle</artifactId>
+            <version>${rng.checkstyle.dep.version}</version>
+          </dependency>
+        </dependencies>
+        <configuration>
+          <includeTestSourceDirectory>true</includeTestSourceDirectory>
+          <configLocation>${rng.parent.dir}/src/main/resources/checkstyle/checkstyle.xml</configLocation>
+          <headerLocation>${rng.parent.dir}/src/main/resources/checkstyle/license-header.txt</headerLocation>
+          <suppressionsLocation>${rng.parent.dir}/src/main/resources/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
+          <enableRulesSummary>false</enableRulesSummary>
+          <logViolationsToConsole>false</logViolationsToConsole>
+          <failOnViolation>true</failOnViolation>
+          <resourceExcludes>NOTICE.txt,LICENSE.txt,**/pom.properties,**/resolver-status.properties,**/sha512.properties</resourceExcludes>
+          <excludes>**/jmh_generated/**.java</excludes>
+        </configuration>
+        <executions>
+          <execution>
+            <id>validate</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
       <plugin>
         <artifactId>maven-pmd-plugin</artifactId>
         <version>${rng.pmd.version}</version>
@@ -333,8 +381,36 @@
           <component>${rng.jira.component}</component>
         </configuration>
       </plugin>
-      <!-- spotbugs-maven-plugin runs in JDK 8+ profile so not included here -->
-      <!-- maven-checkstyle-plugin runs in JDK 8+ profile so not included here -->
+      <plugin>
+        <groupId>com.github.spotbugs</groupId>
+        <artifactId>spotbugs-maven-plugin</artifactId>
+        <version>${commons.spotbugs.version}</version>
+        <configuration>
+          <threshold>Normal</threshold>
+          <effort>Default</effort>
+          <excludeFilterFile>${rng.parent.dir}/src/main/resources/spotbugs/spotbugs-exclude-filter.xml</excludeFilterFile>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <version>${rng.checkstyle.version}</version>
+        <configuration>
+          <configLocation>${rng.parent.dir}/src/main/resources/checkstyle/checkstyle.xml</configLocation>
+          <headerLocation>${rng.parent.dir}/src/main/resources/checkstyle/license-header.txt</headerLocation>
+          <suppressionsLocation>${rng.parent.dir}/src/main/resources/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
+          <enableRulesSummary>false</enableRulesSummary>
+          <includeResources>false</includeResources>
+          <excludes>**/jmh_generated/**.java</excludes>
+        </configuration>
+        <reportSets>
+          <reportSet>
+            <reports>
+              <report>checkstyle</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
       <plugin>
         <artifactId>maven-pmd-plugin</artifactId>
         <version>${rng.pmd.version}</version>
@@ -578,120 +654,6 @@ This is avoided by creating an empty directory when svn is not available.
         </plugins>
       </build>
     </profile>
-    <!-- Profile for pre-Java 8 builds. -->
-    <profile>
-      <id>pre-jdk8</id>
-      <activation>
-        <jdk>[1.7,1.8)</jdk>
-      </activation>
-      <build>
-        <!-- Alter default goal to avoid javadoc generation.
-          The inclusion of MathJax may require the 'allow-script-in-comments' flag
-          depending on the JDK 7 release version. -->
-        <defaultGoal>clean verify</defaultGoal>
-      </build>
-    </profile>
-    <!-- Profile to allow the use of plugin versions that require Java 8+ -->
-    <profile>
-      <id>jdk8-plugins</id>
-      <activation>
-        <jdk>[1.8,)</jdk>
-      </activation>
-      <properties>
-        <!-- MathJax script inclusion requires additional Javadoc qualifier for Java8 as of 8u121 -->
-        <allowscript.javadoc.qualifier>--allow-script-in-comments</allowscript.javadoc.qualifier>
-        <!-- Check for all javadoc errors -->
-        <doclint.javadoc.qualifier>-Xdoclint:all</doclint.javadoc.qualifier>
-      </properties>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>com.github.spotbugs</groupId>
-            <artifactId>spotbugs-maven-plugin</artifactId>
-            <version>${commons.spotbugs.version}</version>
-            <configuration>
-              <threshold>Normal</threshold>
-              <effort>Default</effort>
-              <excludeFilterFile>${rng.parent.dir}/src/main/resources/spotbugs/spotbugs-exclude-filter.xml</excludeFilterFile>
-            </configuration>
-            <executions>
-              <execution>
-                <phase>verify</phase>
-                <goals>
-                  <goal>check</goal>
-                </goals>
-              </execution>
-            </executions>
-          </plugin>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-checkstyle-plugin</artifactId>
-            <version>${rng.checkstyle.version}</version>
-            <dependencies>
-              <dependency>
-                <groupId>com.puppycrawl.tools</groupId>
-                <artifactId>checkstyle</artifactId>
-                <version>${rng.checkstyle.dep.version}</version>
-              </dependency>
-            </dependencies>
-            <configuration>
-              <includeTestSourceDirectory>true</includeTestSourceDirectory>
-              <configLocation>${rng.parent.dir}/src/main/resources/checkstyle/checkstyle.xml</configLocation>
-              <headerLocation>${rng.parent.dir}/src/main/resources/checkstyle/license-header.txt</headerLocation>
-              <suppressionsLocation>${rng.parent.dir}/src/main/resources/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
-              <enableRulesSummary>false</enableRulesSummary>
-              <logViolationsToConsole>false</logViolationsToConsole>
-              <failOnViolation>true</failOnViolation>
-              <resourceExcludes>NOTICE.txt,LICENSE.txt,**/pom.properties,**/resolver-status.properties,**/sha512.properties</resourceExcludes>
-              <excludes>**/jmh_generated/**.java</excludes>
-            </configuration>
-            <executions>
-              <execution>
-                <id>validate</id>
-                <phase>validate</phase>
-                <goals>
-                  <goal>check</goal>
-                </goals>
-              </execution>
-            </executions>
-          </plugin>
-        </plugins>
-      </build>
-      <reporting>
-        <plugins>
-          <plugin>
-            <groupId>com.github.spotbugs</groupId>
-            <artifactId>spotbugs-maven-plugin</artifactId>
-            <version>${commons.spotbugs.version}</version>
-            <configuration>
-              <threshold>Normal</threshold>
-              <effort>Default</effort>
-              <excludeFilterFile>${rng.parent.dir}/src/main/resources/spotbugs/spotbugs-exclude-filter.xml</excludeFilterFile>
-            </configuration>
-          </plugin>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-checkstyle-plugin</artifactId>
-            <version>${rng.checkstyle.version}</version>
-            <configuration>
-              <configLocation>${rng.parent.dir}/src/main/resources/checkstyle/checkstyle.xml</configLocation>
-              <headerLocation>${rng.parent.dir}/src/main/resources/checkstyle/license-header.txt</headerLocation>
-              <suppressionsLocation>${rng.parent.dir}/src/main/resources/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
-              <enableRulesSummary>false</enableRulesSummary>
-              <includeResources>false</includeResources>
-              <excludes>**/jmh_generated/**.java</excludes>
-            </configuration>
-            <reportSets>
-              <reportSet>
-                <reports>
-                  <report>checkstyle</report>
-                </reports>
-              </reportSet>
-            </reportSets>
-          </plugin>
-        </plugins>
-      </reporting>
-    </profile>
     <profile>
       <id>clirr-check</id>
       <activation>

[commons-rng] 03/12: Drop clirr plugin. It is superceded by japicmp

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1980c1c3d20dabb986a1c764c40c11ab1d8e40fb
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Aug 13 19:11:00 2021 +0100

    Drop clirr plugin. It is superceded by japicmp
    
    clirr does support new Java 8 language functions features such as lambda
    expressions.
---
 .../src/site/resources/profile.clirr               | 17 --------------
 commons-rng-core/src/site/resources/profile.clirr  | 17 --------------
 .../src/site/resources/profile.clirr               | 17 --------------
 .../src/site/resources/profile.clirr               | 17 --------------
 pom.xml                                            | 26 ----------------------
 5 files changed, 94 deletions(-)

diff --git a/commons-rng-client-api/src/site/resources/profile.clirr b/commons-rng-client-api/src/site/resources/profile.clirr
deleted file mode 100644
index 6fe28ff..0000000
--- a/commons-rng-client-api/src/site/resources/profile.clirr
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# -----------------------------------------------------------------------------
-#
-# Empty file used to automatically trigger profile from commons parent pom
diff --git a/commons-rng-core/src/site/resources/profile.clirr b/commons-rng-core/src/site/resources/profile.clirr
deleted file mode 100644
index 6fe28ff..0000000
--- a/commons-rng-core/src/site/resources/profile.clirr
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# -----------------------------------------------------------------------------
-#
-# Empty file used to automatically trigger profile from commons parent pom
diff --git a/commons-rng-sampling/src/site/resources/profile.clirr b/commons-rng-sampling/src/site/resources/profile.clirr
deleted file mode 100644
index 6fe28ff..0000000
--- a/commons-rng-sampling/src/site/resources/profile.clirr
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# -----------------------------------------------------------------------------
-#
-# Empty file used to automatically trigger profile from commons parent pom
diff --git a/commons-rng-simple/src/site/resources/profile.clirr b/commons-rng-simple/src/site/resources/profile.clirr
deleted file mode 100644
index 6fe28ff..0000000
--- a/commons-rng-simple/src/site/resources/profile.clirr
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# -----------------------------------------------------------------------------
-#
-# Empty file used to automatically trigger profile from commons parent pom
diff --git a/pom.xml b/pom.xml
index 9ebd193..374ac64 100644
--- a/pom.xml
+++ b/pom.xml
@@ -53,7 +53,6 @@
     <commons.encoding>UTF-8</commons.encoding>
     <maven.compiler.source>1.8</maven.compiler.source>
     <maven.compiler.target>1.8</maven.compiler.target>
-    <rng.clirr.version>2.8</rng.clirr.version>
     <rng.pmd.version>3.14.0</rng.pmd.version>
     <rng.pmd.dep.version>6.37.0</rng.pmd.dep.version>
     <rng.checkstyle.version>3.1.2</rng.checkstyle.version>
@@ -654,31 +653,6 @@ This is avoided by creating an empty directory when svn is not available.
         </plugins>
       </build>
     </profile>
-    <profile>
-      <id>clirr-check</id>
-      <activation>
-        <file>
-          <exists>src/site/resources/profile.clirr</exists>
-        </file>
-      </activation>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.codehaus.mojo</groupId>
-            <artifactId>clirr-maven-plugin</artifactId>
-            <version>${rng.clirr.version}</version>
-            <executions>
-              <execution>
-                <phase>verify</phase>
-                <goals>
-                  <goal>check</goal>
-                </goals>
-              </execution>
-            </executions>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
 
     <!--
         Profiles for modules with special requirements.

[commons-rng] 08/12: Update minimum java version in chamges log

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 927149719d748f964c2b5485541e989d33e17236
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Aug 13 19:45:17 2021 +0100

    Update minimum java version in chamges log
---
 src/changes/changes.xml | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 8f17412..aa14a0c 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -57,17 +57,17 @@ If the output is not quite correct, check for invisible trailing spaces!
 This is a minor release of Apache Commons RNG, containing a
 few new features and performance improvements.
 Apache Commons RNG 1.4 contains the following library modules:
-  commons-rng-client-api (requires Java 7)
-  commons-rng-core (requires Java 7)
-  commons-rng-simple (requires Java 7)
-  commons-rng-sampling (requires Java 7)
+  commons-rng-client-api (requires Java 8)
+  commons-rng-core (requires Java 8)
+  commons-rng-simple (requires Java 8)
+  commons-rng-sampling (requires Java 8)
 The code in module 'commons-rng-core' should not be accessed
 directly by applications as a future release might make use of
 the JPMS modularization feature available in Java 11+.
 
 Additional code is provided in the following modules:
-  commons-rng-examples-quadrature (requires Java 7)
-  commons-rng-examples-jmh (requires Java 7)
+  commons-rng-examples-quadrature (requires Java 8)
+  commons-rng-examples-jmh (requires Java 8)
   commons-rng-examples-sampling (requires Java 8)
   commons-rng-examples-stress (requires Java 8)
   commons-rng-examples-jpms (requires Java 11)
@@ -81,6 +81,9 @@ re-run tests that fail, and pass the build if they succeed
 within the allotted number of reruns (the test will be marked
 as 'flaky' in the report).
 ">
+      <action dev="aherbert" type="update" issue="162">
+        Update the minimum Java version to 1.8.
+      </action>
       <action dev="aherbert" type="update" issue="160">
         "ZigguratSampler.NormalizedGaussian": Performance improvement by extracting ziggurat
         edge sampling to a separate method.
@@ -89,9 +92,6 @@ as 'flaky' in the report).
         "ZigguratSampler.NormalizedGaussian": Corrected biased sampling within convex regions
         at the edge of the ziggurat.
       </action>
-      <action dev="aherbert" type="update" issue="158">
-        Update the minimum Java version to 1.7.
-      </action>
       <action dev="aherbert" type="add" issue="156">
         New "DirichletSampler" class to sample from a Dirichlet distribution.
       </action>

[commons-rng] 04/12: Use JDK 8 Double.isFinite and Math.nextUp/Down

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d04082e8e1091fb3da0f892ad28576098ac20332
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Aug 13 19:31:42 2021 +0100

    Use JDK 8 Double.isFinite and Math.nextUp/Down
---
 .../rng/sampling/distribution/GaussianSampler.java |  3 +-
 .../sampling/distribution/PoissonSamplerCache.java |  2 +-
 .../rng/sampling/distribution/StableSampler.java   |  3 +-
 .../commons/rng/sampling/shape/Coordinates.java    | 13 +--
 .../rng/sampling/UnitSphereSamplerTest.java        |  2 +-
 .../distribution/ContinuousUniformSamplerTest.java | 10 +--
 .../distribution/GeometricSamplerTest.java         |  2 +-
 .../distribution/LargeMeanPoissonSamplerTest.java  |  2 +-
 .../MarsagliaTsangWangDiscreteSamplerTest.java     |  4 +-
 .../distribution/PoissonSamplerCacheTest.java      | 18 ++--
 .../sampling/distribution/StableSamplerTest.java   | 98 +++++++---------------
 11 files changed, 54 insertions(+), 103 deletions(-)

diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GaussianSampler.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GaussianSampler.java
index 38e0537..7601993 100644
--- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GaussianSampler.java
+++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GaussianSampler.java
@@ -54,8 +54,7 @@ public class GaussianSampler implements SharedStateContinuousSampler {
             throw new IllegalArgumentException(
                 "standard deviation is not strictly positive and finite: " + standardDeviation);
         }
-        // To be replaced by JDK 1.8 Double.isFinite. This will detect NaN values.
-        if (!(Math.abs(mean) <= Double.MAX_VALUE)) {
+        if (!Double.isFinite(mean)) {
             throw new IllegalArgumentException("mean is not finite: " + mean);
         }
         this.normalized = normalized;
diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCache.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCache.java
index e935d2b..d918e7d 100644
--- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCache.java
+++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCache.java
@@ -301,7 +301,7 @@ public class PoissonSamplerCache {
      */
     public double getMaxMean() {
         if (isValidRange()) {
-            return Math.nextAfter(maxN + 1.0, -1);
+            return Math.nextDown(maxN + 1.0);
         }
         return 0;
     }
diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/StableSampler.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/StableSampler.java
index bbf6600..feb86ec 100644
--- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/StableSampler.java
+++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/StableSampler.java
@@ -1483,8 +1483,7 @@ public abstract class StableSampler implements SharedStateContinuousSampler {
         if (!(0 < gamma && gamma <= Double.MAX_VALUE)) {
             throw new IllegalArgumentException("gamma is not strictly positive and finite: " + gamma);
         }
-        // To be replaced by !Double.isFinite(double) from JDK 1.8.
-        if (!(Math.abs(delta) <= Double.MAX_VALUE)) {
+        if (!Double.isFinite(delta)) {
             throw new IllegalArgumentException("delta is not finite: " + delta);
         }
     }
diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/Coordinates.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/Coordinates.java
index a1f1fc2..e9a73d9 100644
--- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/Coordinates.java
+++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/Coordinates.java
@@ -45,7 +45,7 @@ final class Coordinates {
      */
     static double[] requireFinite(double[] values, String message) {
         for (final double value : values) {
-            if (!isFinite(value)) {
+            if (!Double.isFinite(value)) {
                 throw new IllegalArgumentException(message + " contains non-finite value: " + value);
             }
         }
@@ -53,17 +53,6 @@ final class Coordinates {
     }
 
     /**
-     * Checks if the value is finite.
-     * To be replaced by {@code Double.isFinite(double)} when source requires Java 8.
-     *
-     * @param value the value
-     * @return true if finite
-     */
-    private static boolean isFinite(double value) {
-        return Math.abs(value) <= Double.MAX_VALUE;
-    }
-
-    /**
      * Check that the values is the specified length. This method is primarily for
      * parameter validation in methods and constructors, for example:
      *
diff --git a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/UnitSphereSamplerTest.java b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/UnitSphereSamplerTest.java
index 2a304e8..d731a98 100644
--- a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/UnitSphereSamplerTest.java
+++ b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/UnitSphereSamplerTest.java
@@ -443,7 +443,7 @@ public class UnitSphereSamplerTest {
     public void testNextNormSquaredAfterZeroIsValid() {
         // The sampler explicitly handles length == 0 using recursion.
         // Anything above zero should be valid.
-        final double normSq = Math.nextAfter(0.0, 1);
+        final double normSq = Math.nextUp(0.0);
         // Map to the scaling factor
         final double f = 1 / Math.sqrt(normSq);
         // As long as this is finite positive then the sampler is valid
diff --git a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSamplerTest.java b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSamplerTest.java
index 76d56a4..9db2c6e 100644
--- a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSamplerTest.java
+++ b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSamplerTest.java
@@ -105,10 +105,10 @@ public class ContinuousUniformSamplerTest {
             {-Double.MIN_VALUE, Double.MIN_VALUE},
             // Same signs. Requires one double inside the range.
             // Same exponent
-            {1.23, Math.nextAfter(1.23, Double.POSITIVE_INFINITY)},
-            {1.23, Math.nextAfter(1.23, Double.NEGATIVE_INFINITY)},
+            {1.23, Math.nextUp(1.23)},
+            {1.23, Math.nextUp(1.23)},
             // Different exponent
-            {2.0, Math.nextAfter(2.0, Double.NEGATIVE_INFINITY)},
+            {2.0, Math.nextDown(2.0)},
         }) {
             final double low = interval[0];
             final double high = interval[1];
@@ -145,8 +145,8 @@ public class ContinuousUniformSamplerTest {
         for (final double expected : new double[] {
             1.23, 2, 56787.7893, 3 * x, 2 * x, x
         }) {
-            final double low = Math.nextAfter(expected, Double.POSITIVE_INFINITY);
-            final double high = Math.nextAfter(expected, Double.NEGATIVE_INFINITY);
+            final double low = Math.nextUp(expected);
+            final double high = Math.nextDown(expected);
             Assert.assertEquals(expected, ContinuousUniformSampler.of(rng, low, high, true).sample(), 0.0);
             Assert.assertEquals(expected, ContinuousUniformSampler.of(rng, high, low, true).sample(), 0.0);
             Assert.assertEquals(-expected, ContinuousUniformSampler.of(rng, -low, -high, true).sample(), 0.0);
diff --git a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java
index a04d841..53f0585 100644
--- a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java
+++ b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java
@@ -48,7 +48,7 @@ public class GeometricSamplerTest {
     public void testProbabilityOfSuccessUnderOneIsValid() {
         // The sampler explicitly handles probabilityOfSuccess == 1 as an edge case.
         // Anything under it should be valid for sampling from an ExponentialDistribution.
-        final double probabilityOfSuccess = Math.nextAfter(1, -1);
+        final double probabilityOfSuccess = Math.nextDown(1);
         // Map to the mean
         final double exponentialMean = 1.0 / (-Math.log1p(-probabilityOfSuccess));
         // As long as this is finite positive then the sampler is valid
diff --git a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/LargeMeanPoissonSamplerTest.java b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/LargeMeanPoissonSamplerTest.java
index c56ae8e..dbdfa6b 100644
--- a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/LargeMeanPoissonSamplerTest.java
+++ b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/LargeMeanPoissonSamplerTest.java
@@ -51,7 +51,7 @@ public class LargeMeanPoissonSamplerTest {
     public void testConstructorThrowsWithMeanBelow1() {
         final RestorableUniformRandomProvider rng =
                 RandomSource.SPLIT_MIX_64.create(0L);
-        final double mean = Math.nextAfter(1, -1);
+        final double mean = Math.nextDown(1);
         LargeMeanPoissonSampler.of(rng, mean);
     }
 
diff --git a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/MarsagliaTsangWangDiscreteSamplerTest.java b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/MarsagliaTsangWangDiscreteSamplerTest.java
index e2e2b9e..8e3573c 100644
--- a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/MarsagliaTsangWangDiscreteSamplerTest.java
+++ b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/MarsagliaTsangWangDiscreteSamplerTest.java
@@ -467,7 +467,7 @@ public class MarsagliaTsangWangDiscreteSamplerTest {
         // Validate set-up
         Assert.assertEquals("Invalid test set-up for p(0)", Double.MIN_VALUE, getBinomialP0(trials, p), 0);
 
-        // Search for larger p until Math.nextAfter(p, 1) produces 0
+        // Search for larger p until Math.nextUp(p) produces 0
         double upper = p * 2;
         Assert.assertEquals("Invalid test set-up for p(0)", 0, getBinomialP0(trials, upper), 0);
 
@@ -484,7 +484,7 @@ public class MarsagliaTsangWangDiscreteSamplerTest {
 
         // Re-validate
         Assert.assertEquals("Invalid test set-up for p(0)", Double.MIN_VALUE, getBinomialP0(trials, p), 0);
-        Assert.assertEquals("Invalid test set-up for p(0)", 0, getBinomialP0(trials, Math.nextAfter(p, 1)), 0);
+        Assert.assertEquals("Invalid test set-up for p(0)", 0, getBinomialP0(trials, Math.nextUp(p)), 0);
 
         final DiscreteSampler sampler = MarsagliaTsangWangDiscreteSampler.Binomial.of(rng, trials, p);
         // This will throw if the table does not sum to 2^30
diff --git a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCacheTest.java b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCacheTest.java
index 7ce5c00..85490e9 100644
--- a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCacheTest.java
+++ b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCacheTest.java
@@ -75,7 +75,7 @@ public class PoissonSamplerCacheTest {
         final PoissonSamplerCache cache = createPoissonSamplerCache(min, max);
         Assert.assertTrue(cache.isValidRange());
         Assert.assertEquals(min, cache.getMinMean(), 0);
-        Assert.assertEquals(Math.nextAfter(Math.floor(max) + 1, -1),
+        Assert.assertEquals(Math.nextDown(Math.floor(max) + 1),
                             cache.getMaxMean(), 0);
     }
 
@@ -91,7 +91,7 @@ public class PoissonSamplerCacheTest {
         final PoissonSamplerCache cache = createPoissonSamplerCache(min, max);
         Assert.assertTrue(cache.isValidRange());
         Assert.assertEquals(min, cache.getMinMean(), 0);
-        Assert.assertEquals(Math.nextAfter(Math.floor(max) + 1, -1),
+        Assert.assertEquals(Math.nextDown(Math.floor(max) + 1),
                             cache.getMaxMean(), 0);
     }
 
@@ -101,7 +101,7 @@ public class PoissonSamplerCacheTest {
     @Test(expected = IllegalArgumentException.class)
     public void testConstructorThrowsWhenMaxIsLessThanMin() {
         final double min = PoissonSampler.PIVOT;
-        final double max = Math.nextAfter(min, -1);
+        final double max = Math.nextDown(min);
         createPoissonSamplerCache(min, max);
     }
 
@@ -116,7 +116,7 @@ public class PoissonSamplerCacheTest {
         final PoissonSamplerCache cache = createPoissonSamplerCache(min, max);
         Assert.assertTrue(cache.isValidRange());
         Assert.assertEquals(PoissonSampler.PIVOT, cache.getMinMean(), 0);
-        Assert.assertEquals(Math.nextAfter(Math.floor(max) + 1, -1),
+        Assert.assertEquals(Math.nextDown(Math.floor(max) + 1),
                             cache.getMaxMean(), 0);
     }
 
@@ -161,7 +161,7 @@ public class PoissonSamplerCacheTest {
         final PoissonSamplerCache cache = createPoissonSamplerCache().withRange(min, max);
         Assert.assertTrue(cache.isValidRange());
         Assert.assertEquals(min, cache.getMinMean(), 0);
-        Assert.assertEquals(Math.nextAfter(Math.floor(max) + 1, -1),
+        Assert.assertEquals(Math.nextDown(Math.floor(max) + 1),
                             cache.getMaxMean(), 0);
     }
 
@@ -177,7 +177,7 @@ public class PoissonSamplerCacheTest {
         final PoissonSamplerCache cache = createPoissonSamplerCache().withRange(min, max);
         Assert.assertTrue(cache.isValidRange());
         Assert.assertEquals(min, cache.getMinMean(), 0);
-        Assert.assertEquals(Math.nextAfter(Math.floor(max) + 1, -1),
+        Assert.assertEquals(Math.nextDown(Math.floor(max) + 1),
                             cache.getMaxMean(), 0);
     }
 
@@ -187,7 +187,7 @@ public class PoissonSamplerCacheTest {
     @Test(expected = IllegalArgumentException.class)
     public void testWithRangeConstructorThrowsWhenMaxIsLessThanMin() {
         final double min = PoissonSampler.PIVOT;
-        final double max = Math.nextAfter(min, -1);
+        final double max = Math.nextDown(min);
         createPoissonSamplerCache().withRange(min, max);
     }
 
@@ -202,7 +202,7 @@ public class PoissonSamplerCacheTest {
         final PoissonSamplerCache cache = createPoissonSamplerCache().withRange(min, max);
         Assert.assertTrue(cache.isValidRange());
         Assert.assertEquals(PoissonSampler.PIVOT, cache.getMinMean(), 0);
-        Assert.assertEquals(Math.nextAfter(Math.floor(max) + 1, -1),
+        Assert.assertEquals(Math.nextDown(Math.floor(max) + 1),
                             cache.getMaxMean(), 0);
     }
 
@@ -216,7 +216,7 @@ public class PoissonSamplerCacheTest {
         final PoissonSamplerCache cache = createPoissonSamplerCache(0, 0).withRange(min, max);
         Assert.assertTrue(cache.isValidRange());
         Assert.assertEquals(min, cache.getMinMean(), 0);
-        Assert.assertEquals(Math.nextAfter(Math.floor(max) + 1, -1),
+        Assert.assertEquals(Math.nextDown(Math.floor(max) + 1),
                             cache.getMaxMean(), 0);
     }
 
diff --git a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/StableSamplerTest.java b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/StableSamplerTest.java
index f56dbc7..efe2c02 100644
--- a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/StableSamplerTest.java
+++ b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/StableSamplerTest.java
@@ -65,7 +65,7 @@ public class StableSamplerTest {
     /** A largest sample from the ZigguratSampler.Exponential after 4 recursions of the sample method.  */
     private static final double LARGE_W = 4 * TAIL_W;
     /** The smallest value for alpha where 1 - (1-alpha) = alpha. */
-    private static final double SMALLEST_ALPHA = 1.0 - nextDown(1.0);
+    private static final double SMALLEST_ALPHA = 1.0 - Math.nextDown(1.0);
 
     private static final double VALID_ALPHA = 1.23;
     private static final double VALID_BETA = 0.23;
@@ -79,7 +79,7 @@ public class StableSamplerTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void testAlphaBelowZeroThrows() {
-        createStableSampler(nextDown(0.0), VALID_BETA, VALID_GAMMA, VALID_DELTA);
+        createStableSampler(Math.nextDown(0.0), VALID_BETA, VALID_GAMMA, VALID_DELTA);
     }
 
     @Test(expected = IllegalArgumentException.class)
@@ -101,7 +101,7 @@ public class StableSamplerTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void testAlphaAboveTwoThrows() {
-        createStableSampler(nextUp(2.0), VALID_BETA, VALID_GAMMA, VALID_DELTA);
+        createStableSampler(Math.nextUp(2.0), VALID_BETA, VALID_GAMMA, VALID_DELTA);
     }
 
     @Test(expected = IllegalArgumentException.class)
@@ -111,12 +111,12 @@ public class StableSamplerTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void testBetaBelowMinusOneThrows() {
-        createStableSampler(VALID_ALPHA, nextDown(-1.0), VALID_GAMMA, VALID_DELTA);
+        createStableSampler(VALID_ALPHA, Math.nextDown(-1.0), VALID_GAMMA, VALID_DELTA);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBetaAboveOneThrows() {
-        createStableSampler(VALID_ALPHA, nextUp(1.0), VALID_GAMMA, VALID_DELTA);
+        createStableSampler(VALID_ALPHA, Math.nextUp(1.0), VALID_GAMMA, VALID_DELTA);
     }
 
     @Test(expected = IllegalArgumentException.class)
@@ -224,15 +224,15 @@ public class StableSamplerTest {
         Assert.assertEquals(-0.5, CMSStableSampler.getTau(0.5, -beta), 0.0);
 
         // Check monototic at the transition point to switch to a different computation.
-        final double tau1 = CMSStableSampler.getTau(nextDown(1.5), 1);
+        final double tau1 = CMSStableSampler.getTau(Math.nextDown(1.5), 1);
         final double tau2 = CMSStableSampler.getTau(1.5, 1);
-        final double tau3 = CMSStableSampler.getTau(nextUp(1.5), 1);
+        final double tau3 = CMSStableSampler.getTau(Math.nextUp(1.5), 1);
         Assert.assertTrue(tau1 > tau2);
         Assert.assertTrue(tau2 > tau3);
         // Test symmetry at the transition
-        Assert.assertEquals(tau1, CMSStableSampler.getTau(2 - nextDown(1.5), 1), 0.0);
+        Assert.assertEquals(tau1, CMSStableSampler.getTau(2 - Math.nextDown(1.5), 1), 0.0);
         Assert.assertEquals(tau2, CMSStableSampler.getTau(0.5, 1), 0.0);
-        Assert.assertEquals(tau3, CMSStableSampler.getTau(2 - nextUp(1.5), 1), 0.0);
+        Assert.assertEquals(tau3, CMSStableSampler.getTau(2 - Math.nextUp(1.5), 1), 0.0);
     }
 
     /**
@@ -292,7 +292,7 @@ public class StableSamplerTest {
             // phiby2 in (-pi/4, pi/4)
             // a in (-1, 1)
             final double a = phiby2 * SpecialMath.tan2(phiby2);
-            Assert.assertEquals(Math.copySign(nextDown(1.0), phiby2), a, 0.0);
+            Assert.assertEquals(Math.copySign(Math.nextDown(1.0), phiby2), a, 0.0);
             final double da = a * a;
             final double a2 = 1 - da;
             // The number is close to but not equal to zero
@@ -388,8 +388,8 @@ public class StableSamplerTest {
         Assert.assertEquals(0.0, computeNumerator(2, beta, x00), 0.0);
         Assert.assertTrue(0.0 < computeNumerator(2, beta, x0));
         Assert.assertTrue(0.0 < computeNumerator(2, beta, x1));
-        Assert.assertTrue(0.0 < computeNumerator(nextDown(2), beta, x0));
-        Assert.assertTrue(0.0 < computeNumerator(nextDown(2), beta, x1));
+        Assert.assertTrue(0.0 < computeNumerator(Math.nextDown(2), beta, x0));
+        Assert.assertTrue(0.0 < computeNumerator(Math.nextDown(2), beta, x1));
 
         // alpha=1 case the numerator reduces to:
         // 1 + 2 * phi/2 * tau
@@ -409,7 +409,7 @@ public class StableSamplerTest {
         // beta < 1 => u < 0
         // beta > -1 => u > 1
         // z=0 not possible with any other beta
-        Assert.assertTrue(0.0 < computeNumerator(alpha, nextUp(-1), x00));
+        Assert.assertTrue(0.0 < computeNumerator(alpha, Math.nextUp(-1), x00));
     }
 
     /**
@@ -539,7 +539,7 @@ public class StableSamplerTest {
         final UniformRandomProvider rng = RandomSource.XO_SHI_RO_256_SS.create();
 
         // The term is mirrored around 1 so use extremes between 1 and 0
-        final double[] alphas = {1, nextDown(1), 0.99, 0.5, 0.1, 0.05, 0.01, DU};
+        final double[] alphas = {1, Math.nextDown(1), 0.99, 0.5, 0.1, 0.05, 0.01, DU};
         // Longs to generate extremes for the angle phi. This is mirrored
         // by negation is the assert method so use values to create phi in [0, pi/2).
         final long[] xs = {0, 1 << 10, Long.MIN_VALUE >>> 1, Long.MAX_VALUE};
@@ -668,13 +668,13 @@ public class StableSamplerTest {
         // Test monotonic at the switch point
         Assert.assertEquals(d2(0.5), d2b(0.5), 0.0);
         // When positive x -> 0 the value smaller bigger.
-        Assert.assertTrue(d2(nextDown(0.5)) <= d2b(0.5));
+        Assert.assertTrue(d2(Math.nextDown(0.5)) <= d2b(0.5));
         Assert.assertEquals(d2(-0.5), d2b(-0.5), 0.0);
         // When negative x -> 0 the value gets bigger.
-        Assert.assertTrue(d2(-nextDown(0.5)) >= d2b(-0.5));
+        Assert.assertTrue(d2(-Math.nextDown(0.5)) >= d2b(-0.5));
         // Potentially the next power of 2 could be used based on ULP errors but
         // the switch is not monotonic.
-        Assert.assertFalse(d2(nextDown(0.25)) <= d2b(0.25));
+        Assert.assertFalse(d2(Math.nextDown(0.25)) <= d2b(0.25));
     }
 
     /**
@@ -899,9 +899,9 @@ public class StableSamplerTest {
         Assert.assertEquals(1.0, PI_4 * SpecialMath.tan2(PI_4), Math.ulp(1.0));
         // If this is above 1 then the sampler will break. Test at the switch point pi/4.
         Assert.assertTrue(1.0 >= PI_4 * SpecialMath.tan2(PI_4));
-        Assert.assertTrue(1.0 >= PI_4 * SpecialMath.tan2(nextDown(PI_4)));
+        Assert.assertTrue(1.0 >= PI_4 * SpecialMath.tan2(Math.nextDown(PI_4)));
         // Monotonic function at the transition
-        Assert.assertTrue(SpecialMath.tan2(nextUp(PI_4)) >= SpecialMath.tan2(PI_4));
+        Assert.assertTrue(SpecialMath.tan2(Math.nextUp(PI_4)) >= SpecialMath.tan2(PI_4));
     }
 
     /**
@@ -991,7 +991,7 @@ public class StableSamplerTest {
                     for (final double u : us) {
                         // CMS formulas
                         double x0 = sampleCMS(1, beta, w, u);
-                        Assert.assertTrue("Target must be finite", isFinite(x0));
+                        Assert.assertTrue("Target must be finite", Double.isFinite(x0));
 
                         // Sample should approach x0 as alpha approaches 1
                         double delta = deltaStart;
@@ -1007,7 +1007,7 @@ public class StableSamplerTest {
 
                         // Weron formulas
                         x0 = sampleWeronAlpha1(beta, w, u);
-                        Assert.assertTrue("Target must be finite", isFinite(x0));
+                        Assert.assertTrue("Target must be finite", Double.isFinite(x0));
 
                         // Sample should approach x0 as alpha approaches 1
                         delta = deltaStart;
@@ -1042,11 +1042,11 @@ public class StableSamplerTest {
     public void testExtremeInputsToSample() {
         // Demonstrate instability when w = 0
         Assert.assertEquals(Double.NaN, sampleCMS(1.3, 0.7, 0, 0.25), 0.0);
-        Assert.assertTrue(isFinite(sampleCMS(1.3, 0.7, SMALL_W, 0.25)));
+        Assert.assertTrue(Double.isFinite(sampleCMS(1.3, 0.7, SMALL_W, 0.25)));
 
         // Demonstrate instability when u -> 0 or 1, and |beta| = 1
         Assert.assertEquals(Double.NaN, sampleCMS(1.1, 1.0, 0.1, 0), 0.0);
-        Assert.assertTrue(isFinite(sampleCMS(1.1, 1.0, 0.1, DU)));
+        Assert.assertTrue(Double.isFinite(sampleCMS(1.1, 1.0, 0.1, DU)));
 
         // Demonstrate instability when alpha -> 0
 
@@ -1058,7 +1058,7 @@ public class StableSamplerTest {
         Assert.assertEquals(Double.NaN, sampleCMS(1e-5, 0.7, 1.0, 1e-4), 0.0);
         Assert.assertEquals(Double.NaN, sampleCMS(1e-5, -0.7, 1.0, 1 - 1e-4), 0.0);
 
-        final double[] alphas = {nextDown(2), 1.3, 1.1, nextUp(1), 1, nextDown(1), 0.7, 0.1, 0.05, 0.01, 0x1.0p-16};
+        final double[] alphas = {Math.nextDown(2), 1.3, 1.1, Math.nextUp(1), 1, Math.nextDown(1), 0.7, 0.1, 0.05, 0.01, 0x1.0p-16};
         final double[] betas = {1, 0.9, 0.001, 0};
         // Avoid zero for the exponential sample.
         // Test the smallest non-zero sample from the ArhensDieter exponential sampler,
@@ -1375,7 +1375,7 @@ public class StableSamplerTest {
 
         final StableSampler sampler = StableSampler.of(createRngWithSequence(longs), alpha, beta);
         // It should not be NaN or infinite
-        Assert.assertTrue("Sampler did not recover", isFinite(sampler.sample()));
+        Assert.assertTrue("Sampler did not recover", Double.isFinite(sampler.sample()));
     }
 
     /**
@@ -1510,7 +1510,7 @@ public class StableSamplerTest {
         }, longs1);
         final StableSampler sampler1 = StableSampler.of(createRngWithSequence(longs1), 1.0, 1.0);
         final double x1 = sampler1.sample();
-        Assert.assertTrue("Sampler did not recover", isFinite(x1));
+        Assert.assertTrue("Sampler did not recover", Double.isFinite(x1));
 
         // u -> pi/4
         final long[] longs2 = {Long.MAX_VALUE, 1446480648965178882L};
@@ -1519,7 +1519,7 @@ public class StableSamplerTest {
         }, longs2);
         final StableSampler sampler2 = StableSampler.of(createRngWithSequence(longs2), 1.0, -1.0);
         final double x2 = sampler2.sample();
-        Assert.assertTrue("Sampler did not recover", isFinite(x2));
+        Assert.assertTrue("Sampler did not recover", Double.isFinite(x2));
 
         // Sample should be a reflection
         Assert.assertEquals(x1, -x2, 0.0);
@@ -1562,7 +1562,7 @@ public class StableSamplerTest {
      */
     private static void testSupport(double gamma, double delta) {
         // When alpha is small (<=0.1) the computation becomes limited by floating-point precision.
-        final double[] alphas = {2.0, 1.5, 1.0, nextDown(1), 0.99, 0.75, 0.5, 0.25, 0.1, 0.01};
+        final double[] alphas = {2.0, 1.5, 1.0, Math.nextDown(1), 0.99, 0.75, 0.5, 0.25, 0.1, 0.01};
         for (final double alpha : alphas) {
             testSupport(alpha, 1, gamma, delta);
             testSupport(alpha, -1, gamma, delta);
@@ -1689,7 +1689,7 @@ public class StableSamplerTest {
         if (alpha > 1) {
             mu = beta * Math.tan((2 - meps1) * PI_2);
         } else {
-            // Special case where tan(pi/4) is not 1 (it is nextDown(1.0)).
+            // Special case where tan(pi/4) is not 1 (it is Math.nextDown(1.0)).
             // This is needed when testing the Levy case during sampling.
             if (alpha == 0.5) {
                 mu = -beta;
@@ -2004,7 +2004,7 @@ public class StableSamplerTest {
         // Alpha 1 case
         testSharedStateSampler(1.0, 0.23);
         // Alpha close to 1
-        testSharedStateSampler(nextUp(1.0), 0.23);
+        testSharedStateSampler(Math.nextUp(1.0), 0.23);
         // General case
         testSharedStateSampler(1.3, 0.1);
         // Small alpha cases
@@ -2053,7 +2053,7 @@ public class StableSamplerTest {
         // Alpha 1 case
         testTransformedSampler(1.0, 0.23);
         // Alpha close to 1
-        testTransformedSampler(nextUp(1.0), 0.23);
+        testTransformedSampler(Math.nextUp(1.0), 0.23);
         // General case
         testTransformedSampler(1.3, 0.1);
         // Small alpha case
@@ -2428,40 +2428,4 @@ public class StableSamplerTest {
         Assert.assertEquals(zeta, sampler.sample(), 0.0);
         Assert.assertEquals(zeta, sampler.sample(), 0.0);
     }
-
-    /**
-     * Checks if the value is finite.
-     *
-     * <p>To be replaced by {@code Double.isFinite(double)} from JDK 1.8.
-     *
-     * @param value the value
-     * @return true if finite
-     */
-    private static boolean isFinite(double value) {
-        return Math.abs(value) <= Double.MAX_VALUE;
-    }
-
-    /**
-     * Return the next value after {@code x} in the direction of positive infinity.
-     *
-     * <p>To be replaced by Math.nextUp(double) from JDK 1.8.
-     *
-     * @param x the x
-     * @return the next value up
-     */
-    private static double nextUp(double x) {
-        return Math.nextAfter(x, Double.POSITIVE_INFINITY);
-    }
-
-    /**
-     * Return the next value after {@code x} in the direction of negative infinity.
-     *
-     * <p>To be replaced by Math.nextDown(double) from JDK 1.8.
-     *
-     * @param x the x
-     * @return the next value down
-     */
-    private static double nextDown(double x) {
-        return Math.nextAfter(x, Double.NEGATIVE_INFINITY);
-    }
 }