commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [42/53] [math] MATH-1158.
Date Fri, 25 Mar 2016 15:19:27 GMT
MATH-1158.

Method "createSampler" overridden in "UniformRealDistribution".


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/1d5f8faa
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/1d5f8faa
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/1d5f8faa

Branch: refs/heads/feature-MATH-1158
Commit: 1d5f8faa87a410fdd1141ad82f270ac238293770
Parents: dff43a0
Author: Gilles <erans@apache.org>
Authored: Sat Mar 12 02:14:04 2016 +0100
Committer: Gilles <erans@apache.org>
Committed: Sat Mar 12 02:14:04 2016 +0100

----------------------------------------------------------------------
 .../math4/distribution/UniformRealDistribution.java | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/1d5f8faa/src/main/java/org/apache/commons/math4/distribution/UniformRealDistribution.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/distribution/UniformRealDistribution.java
b/src/main/java/org/apache/commons/math4/distribution/UniformRealDistribution.java
index 5a54a8b..704aa97 100644
--- a/src/main/java/org/apache/commons/math4/distribution/UniformRealDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/UniformRealDistribution.java
@@ -22,6 +22,7 @@ import org.apache.commons.math4.exception.OutOfRangeException;
 import org.apache.commons.math4.exception.util.LocalizedFormats;
 import org.apache.commons.math4.random.RandomGenerator;
 import org.apache.commons.math4.random.Well19937c;
+import org.apache.commons.math4.rng.UniformRandomProvider;
 
 /**
  * Implementation of the uniform real distribution.
@@ -83,6 +84,7 @@ public class UniformRealDistribution extends AbstractRealDistribution {
      * @throws NumberIsTooLargeException if {@code lower >= upper}.
      * @since 3.1
      */
+    @Deprecated
     public UniformRealDistribution(RandomGenerator rng,
                                    double lower,
                                    double upper)
@@ -192,8 +194,22 @@ public class UniformRealDistribution extends AbstractRealDistribution
{
 
     /** {@inheritDoc} */
     @Override
+    @Deprecated
     public double sample()  {
         final double u = random.nextDouble();
         return u * upper + (1 - u) * lower;
     }
+
+    /** {@inheritDoc} */
+    @Override
+    public RealDistribution.Sampler createSampler(final UniformRandomProvider rng) {
+        return new RealDistribution.Sampler() {
+            /** {@inheritDoc} */
+            @Override
+            public double sample() {
+                final double u = random.nextDouble();
+                return u * upper + (1 - u) * lower;
+            }
+        };
+    }
 }


Mime
View raw message