commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [28/50] commons-rng git commit: Define constant as class variable.
Date Mon, 21 Nov 2016 17:04:18 GMT
Define constant as class variable.


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

Branch: refs/heads/master
Commit: c54ee97985f00e0f50bfb36932a179362a38bc6f
Parents: 2753012
Author: Gilles <erans@apache.org>
Authored: Thu Nov 17 19:00:14 2016 +0100
Committer: Gilles <erans@apache.org>
Committed: Thu Nov 17 19:00:14 2016 +0100

----------------------------------------------------------------------
 .../commons/rng/sampling/distribution/PoissonSampler.java       | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c54ee979/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 605678e..94b19d9 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
@@ -39,6 +39,8 @@ import org.apache.commons.rng.UniformRandomProvider;
 public class PoissonSampler
     extends SamplerBase
     implements DiscreteSampler {
+    /** Value for switching sampling algorithm. */
+    private static final double PIVOT = 40;
     /** Mean of the distribution. */
     private final double mean;
     /** Exponential. */
@@ -78,8 +80,7 @@ public class PoissonSampler
      * @return the next sample.
      */
     private long nextPoisson(double meanPoisson) {
-        final double pivot = 40;
-        if (meanPoisson < pivot) {
+        if (meanPoisson < PIVOT) {
             double p = Math.exp(-meanPoisson);
             long n = 0;
             double r = 1;


Mime
View raw message