Repository: commons-rng
Updated Branches:
  refs/heads/master a39895f16 -> 5a5942796


RNG-53: Deprecate class "SamplerBase".


Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/5a594279
Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/5a594279
Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/5a594279

Branch: refs/heads/master
Commit: 5a594279684f3e3fb9b086d985555815c51204b9
Parents: a39895f
Author: Gilles <er...@apache.org>
Authored: Fri Aug 10 15:32:05 2018 +0200
Committer: Gilles <er...@apache.org>
Committed: Fri Aug 10 15:32:05 2018 +0200

----------------------------------------------------------------------
 .../AhrensDieterExponentialSampler.java         | 15 ++++++++-----
 .../AhrensDieterMarsagliaTsangGammaSampler.java | 17 ++++++++++-----
 .../distribution/BoxMullerGaussianSampler.java  | 15 ++++++++-----
 .../distribution/BoxMullerLogNormalSampler.java | 23 +++++++++++++++++---
 .../BoxMullerNormalizedGaussianSampler.java     | 11 +++++-----
 .../sampling/distribution/ChengBetaSampler.java | 15 ++++++++-----
 .../distribution/ContinuousUniformSampler.java  |  9 +++++---
 .../distribution/DiscreteUniformSampler.java    | 11 ++++++----
 .../InverseTransformContinuousSampler.java      | 11 +++++++---
 .../InverseTransformDiscreteSampler.java        | 11 +++++++---
 .../InverseTransformParetoSampler.java          |  9 +++++---
 .../distribution/LargeMeanPoissonSampler.java   | 11 ++++++----
 .../MarsagliaNormalizedGaussianSampler.java     | 11 +++++-----
 .../sampling/distribution/PoissonSampler.java   |  6 +++--
 .../RejectionInversionZipfSampler.java          |  9 +++++---
 .../rng/sampling/distribution/SamplerBase.java  |  5 +++++
 .../distribution/SmallMeanPoissonSampler.java   | 11 ++++++----
 .../ZigguratNormalizedGaussianSampler.java      | 17 ++++++++-------
 src/changes/changes.xml                         | 19 ++++++++--------
 19 files changed, 155 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterExponentialSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterExponentialSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterExponentialSampler.java
index c3b2387..7927d35 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterExponentialSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterExponentialSampler.java
@@ -20,6 +20,8 @@ import org.apache.commons.rng.UniformRandomProvider;
 
 /**
  * Sampling from an <a 
href="http://mathworld.wolfram.com/ExponentialDistribution.html";>exponential 
distribution</a>.
+ *
+ * @since 1.0
  */
 public class AhrensDieterExponentialSampler
     extends SamplerBase
@@ -39,6 +41,8 @@ public class AhrensDieterExponentialSampler
     private static final double[] EXPONENTIAL_SA_QI = new double[16];
     /** The mean of this distribution. */
     private final double mean;
+    /** Underlying source of randomness. */
+    private final UniformRandomProvider rng;
 
     /**
      * Initialize tables.
@@ -63,7 +67,8 @@ public class AhrensDieterExponentialSampler
      */
     public AhrensDieterExponentialSampler(UniformRandomProvider rng,
                                           double mean) {
-        super(rng);
+        super(null);
+        this.rng = rng;
         this.mean = mean;
     }
 
@@ -72,7 +77,7 @@ public class AhrensDieterExponentialSampler
     public double sample() {
         // Step 1:
         double a = 0;
-        double u = nextDouble();
+        double u = rng.nextDouble();
 
         // Step 2 and 3:
         while (u < 0.5) {
@@ -90,13 +95,13 @@ public class AhrensDieterExponentialSampler
 
         // Step 6:
         int i = 0; // Should be 1, be we iterate before it in while using 0.
-        double u2 = nextDouble();
+        double u2 = rng.nextDouble();
         double umin = u2;
 
         // Step 7 and 8:
         do {
             ++i;
-            u2 = nextDouble();
+            u2 = rng.nextDouble();
 
             if (u2 < umin) {
                 umin = u2;
@@ -111,6 +116,6 @@ public class AhrensDieterExponentialSampler
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return "Ahrens-Dieter Exponential deviate [" + super.toString() + "]";
+        return "Ahrens-Dieter Exponential deviate [" + rng.toString() + "]";
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
index cbe327c..d34902d 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
@@ -38,6 +38,8 @@ import org.apache.commons.rng.UniformRandomProvider;
  *   </blockquote>
  *  </li>
  * </ul>
+ *
+ * @since 1.0
  */
 public class AhrensDieterMarsagliaTsangGammaSampler
     extends SamplerBase
@@ -58,6 +60,8 @@ public class AhrensDieterMarsagliaTsangGammaSampler
     private final double cOptim;
     /** Gaussian sampling. */
     private final NormalizedGaussianSampler gaussian;
+    /** Underlying source of randomness. */
+    private final UniformRandomProvider rng;
 
     /**
      * @param rng Generator of uniformly distributed random numbers.
@@ -67,7 +71,8 @@ public class AhrensDieterMarsagliaTsangGammaSampler
     public AhrensDieterMarsagliaTsangGammaSampler(UniformRandomProvider rng,
                                                   double alpha,
                                                   double theta) {
-        super(rng);
+        super(null);
+        this.rng = rng;
         this.alpha = alpha;
         this.theta = theta;
         gaussian = new ZigguratNormalizedGaussianSampler(rng);
@@ -85,14 +90,14 @@ public class AhrensDieterMarsagliaTsangGammaSampler
 
             while (true) {
                 // Step 1:
-                final double u = nextDouble();
+                final double u = rng.nextDouble();
                 final double p = bGSOptim * u;
 
                 if (p <= 1) {
                     // Step 2:
 
                     final double x = Math.pow(p, oneOverTheta);
-                    final double u2 = nextDouble();
+                    final double u2 = rng.nextDouble();
 
                     if (u2 > Math.exp(-x)) {
                         // Reject.
@@ -104,7 +109,7 @@ public class AhrensDieterMarsagliaTsangGammaSampler
                     // Step 3:
 
                     final double x = -Math.log((bGSOptim - p) * oneOverTheta);
-                    final double u2 = nextDouble();
+                    final double u2 = rng.nextDouble();
 
                     if (u2 > Math.pow(x, theta - 1)) {
                         // Reject.
@@ -125,7 +130,7 @@ public class AhrensDieterMarsagliaTsangGammaSampler
                 }
 
                 final double x2 = x * x;
-                final double u = nextDouble();
+                final double u = rng.nextDouble();
 
                 // Squeeze.
                 if (u < 1 - 0.0331 * x2 * x2) {
@@ -142,6 +147,6 @@ public class AhrensDieterMarsagliaTsangGammaSampler
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return "Ahrens-Dieter-Marsaglia-Tsang Gamma deviate [" + 
super.toString() + "]";
+        return "Ahrens-Dieter-Marsaglia-Tsang Gamma deviate [" + 
rng.toString() + "]";
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerGaussianSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerGaussianSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerGaussianSampler.java
index 489cda3..acddb03 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerGaussianSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerGaussianSampler.java
@@ -22,7 +22,9 @@ import org.apache.commons.rng.UniformRandomProvider;
  * <a href="https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform";>
  * Box-Muller algorithm</a> for sampling from a Gaussian distribution.
  *
- * @deprecated since v1.1. Please use {@link 
BoxMullerNormalizedGaussianSampler}
+ * @since 1.0
+ *
+ * @deprecated Since v1.1. Please use {@link 
BoxMullerNormalizedGaussianSampler}
  * and {@link GaussianSampler} instead.
  */
 @Deprecated
@@ -35,6 +37,8 @@ public class BoxMullerGaussianSampler
     private final double mean;
     /** standardDeviation. */
     private final double standardDeviation;
+    /** Underlying source of randomness. */
+    private final UniformRandomProvider rng;
 
     /**
      * @param rng Generator of uniformly distributed random numbers.
@@ -44,7 +48,8 @@ public class BoxMullerGaussianSampler
     public BoxMullerGaussianSampler(UniformRandomProvider rng,
                                     double mean,
                                     double standardDeviation) {
-        super(rng);
+        super(null);
+        this.rng = rng;
         this.mean = mean;
         this.standardDeviation = standardDeviation;
     }
@@ -56,8 +61,8 @@ public class BoxMullerGaussianSampler
         if (Double.isNaN(nextGaussian)) {
             // Generate a pair of Gaussian numbers.
 
-            final double x = nextDouble();
-            final double y = nextDouble();
+            final double x = rng.nextDouble();
+            final double y = rng.nextDouble();
             final double alpha = 2 * Math.PI * x;
             final double r = Math.sqrt(-2 * Math.log(y));
 
@@ -81,6 +86,6 @@ public class BoxMullerGaussianSampler
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return "Box-Muller Gaussian deviate [" + super.toString() + "]";
+        return "Box-Muller Gaussian deviate [" + rng.toString() + "]";
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerLogNormalSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerLogNormalSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerLogNormalSampler.java
index 4be25fd..34953ad 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerLogNormalSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerLogNormalSampler.java
@@ -27,7 +27,11 @@ import org.apache.commons.rng.UniformRandomProvider;
  */
 @Deprecated
 public class BoxMullerLogNormalSampler
-    extends LogNormalSampler {
+    extends SamplerBase
+    implements ContinuousSampler {
+    /** Delegate. */
+    private final ContinuousSampler sampler;
+
     /**
      * @param rng Generator of uniformly distributed random numbers.
      * @param scale Scale of the log-normal distribution.
@@ -36,7 +40,20 @@ public class BoxMullerLogNormalSampler
     public BoxMullerLogNormalSampler(UniformRandomProvider rng,
                                      double scale,
                                      double shape) {
-        super(new BoxMullerNormalizedGaussianSampler(rng),
-              scale, shape);
+        super(null);
+        sampler = new LogNormalSampler(new 
BoxMullerNormalizedGaussianSampler(rng),
+                                       scale, shape);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public double sample() {
+        return sampler.sample();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return sampler.toString();
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerNormalizedGaussianSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerNormalizedGaussianSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerNormalizedGaussianSampler.java
index 43882fb..78a6b74 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerNormalizedGaussianSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerNormalizedGaussianSampler.java
@@ -26,16 +26,17 @@ import org.apache.commons.rng.UniformRandomProvider;
  * @since 1.1
  */
 public class BoxMullerNormalizedGaussianSampler
-    extends SamplerBase
     implements NormalizedGaussianSampler {
     /** Next gaussian. */
     private double nextGaussian = Double.NaN;
+    /** Underlying source of randomness. */
+    private final UniformRandomProvider rng;
 
     /**
      * @param rng Generator of uniformly distributed random numbers.
      */
     public BoxMullerNormalizedGaussianSampler(UniformRandomProvider rng) {
-        super(rng);
+        this.rng = rng;
     }
 
     /** {@inheritDoc} */
@@ -45,8 +46,8 @@ public class BoxMullerNormalizedGaussianSampler
         if (Double.isNaN(nextGaussian)) {
             // Generate a pair of Gaussian numbers.
 
-            final double x = nextDouble();
-            final double y = nextDouble();
+            final double x = rng.nextDouble();
+            final double y = rng.nextDouble();
             final double alpha = 2 * Math.PI * x;
             final double r = Math.sqrt(-2 * Math.log(y));
 
@@ -70,6 +71,6 @@ public class BoxMullerNormalizedGaussianSampler
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return "Box-Muller normalized Gaussian deviate [" + super.toString() + 
"]";
+        return "Box-Muller normalized Gaussian deviate [" + rng.toString() + 
"]";
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ChengBetaSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ChengBetaSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ChengBetaSampler.java
index 1b4249a..ccee2c5 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ChengBetaSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ChengBetaSampler.java
@@ -38,6 +38,8 @@ public class ChengBetaSampler
     private final double alphaShape;
     /** Second shape parameter. */
     private final double betaShape;
+    /** Underlying source of randomness. */
+    private final UniformRandomProvider rng;
 
     /**
      * Creates a sampler instance.
@@ -49,7 +51,8 @@ public class ChengBetaSampler
     public ChengBetaSampler(UniformRandomProvider rng,
                             double alpha,
                             double beta) {
-        super(rng);
+        super(null);
+        this.rng = rng;
         alphaShape = alpha;
         betaShape = beta;
     }
@@ -70,7 +73,7 @@ public class ChengBetaSampler
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return "Cheng Beta deviate [" + super.toString() + "]";
+        return "Cheng Beta deviate [" + rng.toString() + "]";
     }
 
     /**
@@ -91,8 +94,8 @@ public class ChengBetaSampler
         double w;
         double t;
         do {
-            final double u1 = nextDouble();
-            final double u2 = nextDouble();
+            final double u1 = rng.nextDouble();
+            final double u2 = rng.nextDouble();
             final double v = beta * (Math.log(u1) - Math.log1p(-u1));
             w = a * Math.exp(v);
             final double z = u1 * u1 * u2;
@@ -131,8 +134,8 @@ public class ChengBetaSampler
 
         double w;
         while (true) {
-            final double u1 = nextDouble();
-            final double u2 = nextDouble();
+            final double u1 = rng.nextDouble();
+            final double u2 = rng.nextDouble();
             final double y = u1 * u2;
             final double z = u1 * y;
             if (u1 < 0.5) {

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSampler.java
index 4b59e99..57b7488 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSampler.java
@@ -28,6 +28,8 @@ public class ContinuousUniformSampler
     private final double lo;
     /** Higher bound. */
     private final double hi;
+    /** Underlying source of randomness. */
+    private final UniformRandomProvider rng;
 
     /**
      * @param rng Generator of uniformly distributed random numbers.
@@ -37,7 +39,8 @@ public class ContinuousUniformSampler
     public ContinuousUniformSampler(UniformRandomProvider rng,
                                     double lo,
                                     double hi) {
-        super(rng);
+        super(null);
+        this.rng = rng;
         this.lo = lo;
         this.hi = hi;
     }
@@ -45,13 +48,13 @@ public class ContinuousUniformSampler
     /** {@inheritDoc} */
     @Override
     public double sample() {
-        final double u = nextDouble();
+        final double u = rng.nextDouble();
         return u * hi + (1 - u) * lo;
     }
 
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return "Uniform deviate [" + super.toString() + "]";
+        return "Uniform deviate [" + rng.toString() + "]";
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/DiscreteUniformSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/DiscreteUniformSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/DiscreteUniformSampler.java
index 5ee69be..6ff5ec7 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/DiscreteUniformSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/DiscreteUniformSampler.java
@@ -29,6 +29,8 @@ public class DiscreteUniformSampler
     private final int lower;
     /** Upper bound. */
     private final int upper;
+    /** Underlying source of randomness. */
+    private final UniformRandomProvider rng;
 
     /**
      * @param rng Generator of uniformly distributed random numbers.
@@ -39,7 +41,8 @@ public class DiscreteUniformSampler
     public DiscreteUniformSampler(UniformRandomProvider rng,
                                   int lower,
                                   int upper) {
-        super(rng);
+        super(null);
+        this.rng = rng;
         if (lower > upper) {
             throw new IllegalArgumentException(lower  + " > " + upper);
         }
@@ -57,7 +60,7 @@ public class DiscreteUniformSampler
             // than 2^31); as it covers more than half the integer range,
             // we use a simple rejection method.
             while (true) {
-                final int r = nextInt();
+                final int r = rng.nextInt();
                 if (r >= lower &&
                     r <= upper) {
                     return r;
@@ -65,13 +68,13 @@ public class DiscreteUniformSampler
             }
         } else {
             // We can shift the range and directly generate a positive int.
-            return lower + nextInt(max);
+            return lower + rng.nextInt(max);
         }
     }
 
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return "Uniform deviate [" + super.toString() + "]";
+        return "Uniform deviate [" + rng.toString() + "]";
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseTransformContinuousSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseTransformContinuousSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseTransformContinuousSampler.java
index c95bcec..ccaa138 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseTransformContinuousSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseTransformContinuousSampler.java
@@ -50,12 +50,16 @@ import org.apache.commons.rng.UniformRandomProvider;
  * // Generate random deviate.
  * double random = chiSquareSampler.sample();
  * </code></pre>
+ *
+ * @since 1.0
  */
 public class InverseTransformContinuousSampler
     extends SamplerBase
     implements ContinuousSampler {
     /** Inverse cumulative probability function. */
     private final ContinuousInverseCumulativeProbabilityFunction function;
+    /** Underlying source of randomness. */
+    private final UniformRandomProvider rng;
 
     /**
      * @param rng Generator of uniformly distributed random numbers.
@@ -63,19 +67,20 @@ public class InverseTransformContinuousSampler
      */
     public InverseTransformContinuousSampler(UniformRandomProvider rng,
                                              
ContinuousInverseCumulativeProbabilityFunction function) {
-        super(rng);
+        super(null);
+        this.rng = rng;
         this.function = function;
     }
 
     /** {@inheritDoc} */
     @Override
     public double sample() {
-        return function.inverseCumulativeProbability(nextDouble());
+        return function.inverseCumulativeProbability(rng.nextDouble());
     }
 
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return function.toString() + " (inverse method) [" + super.toString() 
+ "]";
+        return function.toString() + " (inverse method) [" + rng.toString() + 
"]";
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseTransformDiscreteSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseTransformDiscreteSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseTransformDiscreteSampler.java
index 4b5b0e7..5c43b58 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseTransformDiscreteSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseTransformDiscreteSampler.java
@@ -50,12 +50,16 @@ import org.apache.commons.rng.UniformRandomProvider;
  * // Generate random deviate.
  * int random = binomialSampler.sample();
  * </code></pre>
+ *
+ * @since 1.0
  */
 public class InverseTransformDiscreteSampler
     extends SamplerBase
     implements DiscreteSampler {
     /** Inverse cumulative probability function. */
     private final DiscreteInverseCumulativeProbabilityFunction function;
+    /** Underlying source of randomness. */
+    private final UniformRandomProvider rng;
 
     /**
      * @param rng Generator of uniformly distributed random numbers.
@@ -63,19 +67,20 @@ public class InverseTransformDiscreteSampler
      */
     public InverseTransformDiscreteSampler(UniformRandomProvider rng,
                                            
DiscreteInverseCumulativeProbabilityFunction function) {
-        super(rng);
+        super(null);
+        this.rng = rng;
         this.function = function;
     }
 
     /** {@inheritDoc} */
     @Override
     public int sample() {
-        return function.inverseCumulativeProbability(nextDouble());
+        return function.inverseCumulativeProbability(rng.nextDouble());
     }
 
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return function.toString() + " (inverse method) [" + super.toString() 
+ "]";
+        return function.toString() + " (inverse method) [" + rng.toString() + 
"]";
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseTransformParetoSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseTransformParetoSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseTransformParetoSampler.java
index 93be592..15a1c90 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseTransformParetoSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseTransformParetoSampler.java
@@ -28,6 +28,8 @@ public class InverseTransformParetoSampler
     private final double scale;
     /** Shape. */
     private final double shape;
+    /** Underlying source of randomness. */
+    private final UniformRandomProvider rng;
 
     /**
      * @param rng Generator of uniformly distributed random numbers.
@@ -37,7 +39,8 @@ public class InverseTransformParetoSampler
     public InverseTransformParetoSampler(UniformRandomProvider rng,
                                          double scale,
                                          double shape) {
-        super(rng);
+        super(null);
+        this.rng = rng;
         this.scale = scale;
         this.shape = shape;
     }
@@ -45,12 +48,12 @@ public class InverseTransformParetoSampler
     /** {@inheritDoc} */
     @Override
     public double sample() {
-        return scale / Math.pow(nextDouble(), 1 / shape);
+        return scale / Math.pow(rng.nextDouble(), 1 / shape);
     }
 
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return "[Inverse method for Pareto distribution " + super.toString() + 
"]";
+        return "[Inverse method for Pareto distribution " + rng.toString() + 
"]";
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/LargeMeanPoissonSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/LargeMeanPoissonSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/LargeMeanPoissonSampler.java
index a729686..6a70113 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/LargeMeanPoissonSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/LargeMeanPoissonSampler.java
@@ -32,10 +32,11 @@ import 
org.apache.commons.rng.sampling.distribution.InternalUtils.FactorialLog;
  *  </li>
  * </ul>
  *
+ * @since 1.1
+ *
  * This sampler is suitable for {@code mean >= 40}.
  */
 public class LargeMeanPoissonSampler
-    extends SamplerBase
     implements DiscreteSampler {
 
     /** Class to compute {@code log(n!)}. This has no cached values. */
@@ -46,6 +47,8 @@ public class LargeMeanPoissonSampler
         NO_CACHE_FACTORIAL_LOG = FactorialLog.create();
     }
 
+    /** Underlying source of randomness. */
+    private final UniformRandomProvider rng;
     /** Exponential. */
     private final ContinuousSampler exponential;
     /** Gaussian. */
@@ -98,7 +101,7 @@ public class LargeMeanPoissonSampler
      */
     public LargeMeanPoissonSampler(UniformRandomProvider rng,
                                    double mean) {
-        super(rng);
+        this.rng = rng;
         if (mean <= 0) {
             throw new IllegalArgumentException(mean + " <= " + 0);
         }
@@ -145,7 +148,7 @@ public class LargeMeanPoissonSampler
         double qr = 0;
         double qa = 0;
         while (true) {
-            final double u = nextDouble();
+            final double u = rng.nextDouble();
             if (u <= p1) {
                 final double n = gaussian.sample();
                 x = n * Math.sqrt(lambda + halfDelta) - 0.5d;
@@ -202,6 +205,6 @@ public class LargeMeanPoissonSampler
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return "Large Mean Poisson deviate [" + super.toString() + "]";
+        return "Large Mean Poisson deviate [" + rng.toString() + "]";
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/MarsagliaNormalizedGaussianSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/MarsagliaNormalizedGaussianSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/MarsagliaNormalizedGaussianSampler.java
index a20d3be..4b64461 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/MarsagliaNormalizedGaussianSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/MarsagliaNormalizedGaussianSampler.java
@@ -28,16 +28,17 @@ import org.apache.commons.rng.UniformRandomProvider;
  * @since 1.1
  */
 public class MarsagliaNormalizedGaussianSampler
-    extends SamplerBase
     implements NormalizedGaussianSampler {
     /** Next gaussian. */
     private double nextGaussian = Double.NaN;
+    /** Underlying source of randomness. */
+    private final UniformRandomProvider rng;
 
     /**
      * @param rng Generator of uniformly distributed random numbers.
      */
     public MarsagliaNormalizedGaussianSampler(UniformRandomProvider rng) {
-        super(rng);
+        this.rng = rng;
     }
 
     /** {@inheritDoc} */
@@ -47,8 +48,8 @@ public class MarsagliaNormalizedGaussianSampler
             // Rejection scheme for selecting a pair that lies within the unit 
circle.
             while (true) {
                 // Generate a pair of numbers within [-1 , 1).
-                final double x = 2 * nextDouble() - 1;
-                final double y = 2 * nextDouble() - 1;
+                final double x = 2 * rng.nextDouble() - 1;
+                final double y = 2 * rng.nextDouble() - 1;
                 final double r2 = x * x + y * y;
 
                 if (r2 < 1 && r2 > 0) {
@@ -79,6 +80,6 @@ public class MarsagliaNormalizedGaussianSampler
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return "Box-Muller (with rejection) normalized Gaussian deviate [" + 
super.toString() + "]";
+        return "Box-Muller (with rejection) normalized Gaussian deviate [" + 
rng.toString() + "]";
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/PoissonSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/PoissonSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/PoissonSampler.java
index d0733ba..246d2cf 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/PoissonSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/PoissonSampler.java
@@ -35,6 +35,8 @@ import org.apache.commons.rng.UniformRandomProvider;
  *   </blockquote>
  *  </li>
  * </ul>
+ *
+ * @since 1.0
  */
 public class PoissonSampler
     extends SamplerBase
@@ -52,7 +54,7 @@ public class PoissonSampler
      */
     public PoissonSampler(UniformRandomProvider rng,
                           double mean) {
-        super(rng);
+        super(null);
 
         // Delegate all work to specialised samplers.
         // These should check the input arguments.
@@ -70,6 +72,6 @@ public class PoissonSampler
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return "Poisson deviate [" + super.toString() + "]";
+        return poissonSampler.toString();
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/RejectionInversionZipfSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/RejectionInversionZipfSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/RejectionInversionZipfSampler.java
index d8eafb2..2e25934 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/RejectionInversionZipfSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/RejectionInversionZipfSampler.java
@@ -45,6 +45,8 @@ public class RejectionInversionZipfSampler
     private final double hIntegralNumberOfElements;
     /** {@code 2 - hIntegralInverse(hIntegral(2.5) - h(2)}. */
     private final double s;
+    /** Underlying source of randomness. */
+    private final UniformRandomProvider rng;
 
     /**
      * @param rng Generator of uniformly distributed random numbers.
@@ -56,7 +58,8 @@ public class RejectionInversionZipfSampler
     public RejectionInversionZipfSampler(UniformRandomProvider rng,
                                          int numberOfElements,
                                          double exponent) {
-        super(rng);
+        super(null);
+        this.rng = rng;
         if (numberOfElements <= 0) {
             throw new IllegalArgumentException("number of elements is not 
strictly positive: " + numberOfElements);
         }
@@ -102,7 +105,7 @@ public class RejectionInversionZipfSampler
         // This explains why the implementation looks slightly different.
 
         while(true) {
-            final double u = hIntegralNumberOfElements + nextDouble() * 
(hIntegralX1 - hIntegralNumberOfElements);
+            final double u = hIntegralNumberOfElements + rng.nextDouble() * 
(hIntegralX1 - hIntegralNumberOfElements);
             // u is uniformly distributed in (hIntegralX1, 
hIntegralNumberOfElements]
 
             double x = hIntegralInverse(u);
@@ -169,7 +172,7 @@ public class RejectionInversionZipfSampler
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return "Rejection inversion Zipf deviate [" + super.toString() + "]";
+        return "Rejection inversion Zipf deviate [" + rng.toString() + "]";
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/SamplerBase.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/SamplerBase.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/SamplerBase.java
index eb74f75..2b1e0a1 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/SamplerBase.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/SamplerBase.java
@@ -20,7 +20,12 @@ import org.apache.commons.rng.UniformRandomProvider;
 
 /**
  * Base class for a sampler.
+ *
+ * @since 1.0
+ *
+ * @deprecated Since version 1.1. Class intended for internal use only.
  */
+@Deprecated
 public class SamplerBase {
     /** RNG. */
     private final UniformRandomProvider rng;

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/SmallMeanPoissonSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/SmallMeanPoissonSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/SmallMeanPoissonSampler.java
index 283594e..170a85b 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/SmallMeanPoissonSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/SmallMeanPoissonSampler.java
@@ -29,10 +29,11 @@ import org.apache.commons.rng.UniformRandomProvider;
  *  </li>
  * </ul>
  *
+ * @since 1.1
+ *
  * This sampler is suitable for {@code mean < 40}.
  */
 public class SmallMeanPoissonSampler
-    extends SamplerBase
     implements DiscreteSampler {
 
     /**
@@ -42,6 +43,8 @@ public class SmallMeanPoissonSampler
     private final double p0;
     /** Pre-compute {@code 1000 * mean} as the upper limit of the sample. */
     private final int limit;
+    /** Underlying source of randomness. */
+    private final UniformRandomProvider rng;
 
     /**
      * @param rng  Generator of uniformly distributed random numbers.
@@ -50,7 +53,7 @@ public class SmallMeanPoissonSampler
      */
     public SmallMeanPoissonSampler(UniformRandomProvider rng,
                                    double mean) {
-        super(rng);
+        this.rng = rng;
         if (mean <= 0) {
             throw new IllegalArgumentException(mean + " <= " + 0);
         }
@@ -67,7 +70,7 @@ public class SmallMeanPoissonSampler
         double r = 1;
 
         while (n < limit) {
-            r *= nextDouble();
+            r *= rng.nextDouble();
             if (r >= p0) {
                 n++;
             } else {
@@ -80,6 +83,6 @@ public class SmallMeanPoissonSampler
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return "Small Mean Poisson deviate [" + super.toString() + "]";
+        return "Small Mean Poisson deviate [" + rng.toString() + "]";
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ZigguratNormalizedGaussianSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ZigguratNormalizedGaussianSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ZigguratNormalizedGaussianSampler.java
index 3571f3b..b52c926 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ZigguratNormalizedGaussianSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ZigguratNormalizedGaussianSampler.java
@@ -31,7 +31,6 @@ import org.apache.commons.rng.UniformRandomProvider;
  * @since 1.1
  */
 public class ZigguratNormalizedGaussianSampler
-    extends SamplerBase
     implements NormalizedGaussianSampler {
     /** Start of tail. */
     private static final double R = 3.442619855899;
@@ -53,6 +52,8 @@ public class ZigguratNormalizedGaussianSampler
     private static final double[] W = new double[LEN];
     /** Auxiliary table. */
     private static final double[] F = new double[LEN];
+    /** Underlying source of randomness. */
+    private final UniformRandomProvider rng;
 
     static {
         // Filling the tables.
@@ -88,13 +89,13 @@ public class ZigguratNormalizedGaussianSampler
      * @param rng Generator of uniformly distributed random numbers.
      */
     public ZigguratNormalizedGaussianSampler(UniformRandomProvider rng) {
-        super(rng);
+        this.rng = rng;
     }
 
     /** {@inheritDoc} */
     @Override
     public double sample() {
-        final long j = nextLong();
+        final long j = rng.nextLong();
         final int i = (int) (j & LAST);
         if (Math.abs(j) < K[i]) {
             return j * W[i];
@@ -106,7 +107,7 @@ public class ZigguratNormalizedGaussianSampler
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        return "Ziggurat normalized Gaussian deviate [" + super.toString() + 
"]";
+        return "Ziggurat normalized Gaussian deviate [" + rng.toString() + "]";
     }
 
     /**
@@ -126,18 +127,18 @@ public class ZigguratNormalizedGaussianSampler
             if (iz == 0) {
                 // Base strip.
                 do {
-                    y = -Math.log(nextDouble());
-                    x = -Math.log(nextDouble()) * ONE_OVER_R;
+                    y = -Math.log(rng.nextDouble());
+                    x = -Math.log(rng.nextDouble()) * ONE_OVER_R;
                 } while (y + y < x * x);
 
                 final double out = R + x;
                 return hz > 0 ? out : -out;
             } else {
                 // Wedge of other strips.
-                if (F[iz] + nextDouble() * (F[iz - 1] - F[iz]) < gauss(x)) {
+                if (F[iz] + rng.nextDouble() * (F[iz - 1] - F[iz]) < gauss(x)) 
{
                     return x;
                 } else {
-                    final long hzNew = nextLong();
+                    final long hzNew = rng.nextLong();
                     final int izNew = (int) (hzNew & LAST);
                     if (Math.abs(hzNew) < K[izNew]) {
                         return hzNew * W[izNew];

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/5a594279/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 262d7f6..0849bc3 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -73,7 +73,7 @@ should be expected in subsequent releases.
 ">
     </release>
 
-    <release version="1.1" date="2018-08-05" description="
+    <release version="1.1" date="2018-08-15" description="
 This is a minor release of Apache Commons RNG, containing a
 few new features and performance improvements.
 
@@ -98,11 +98,16 @@ of random number generation.  The 'maven-surefire-plugin' 
can be configured
 to re-run tests that fail and pass the build if they succeed (the test will
 be marked as 'flaky' in the report).
 ">
+      <action dev="erans" type="fix" issue="RNG-53">
+        Class "SamplerBase" has been deprecated.  It was meant for internal use
+        only but, through inheritance, it allows incorrect usage of the sampler
+        classes.
+      </action>
       <action dev="erans" type="update" issue="RNG-50" due-to="Alex D. 
Herbert">
-       "PoissonSampler": Algorithms for small mean and large mean have
-       been separated into dedicated classes.  Cache precomputation has
-       been disabled as it is only marginally used and is a performance
-       hit for small sampling sets.
+           "PoissonSampler": Algorithms for small mean and large mean have
+           been separated into dedicated classes.  Cache precomputation has
+           been disabled as it is only marginally used and is a performance
+           hit for small sampling sets.
       </action>
       <action dev="erans" type="add" issue="RNG-37">
         Implementation of the "Ziggurat" algorithm for Gaussian sampling.
@@ -119,10 +124,6 @@ be marked as 'flaky' in the report).
       </action>
       <action dev="erans" type="update" issue="RNG-46">
         Following RNG-43, "BoxMullerLogNormalSampler" has been deprecated.
-        Furthermore, its base class has been removed; although it is a binary
-        incompatibility, it cannot cause any problem that were not already
-        present in code using v1.0 of the library: Calls to the base class
-        would have raised a NPE.
       </action>
       <action dev="erans" type="add" issue="RNG-39">
         "UnitSphereSampler": generate random vectors isotropically located

Reply via email to