commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject commons-rng git commit: Duplicate code.
Date Tue, 04 Sep 2018 23:00:42 GMT
Repository: commons-rng
Updated Branches:
  refs/heads/master b9a9d2708 -> f5599152a


Duplicate code.


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

Branch: refs/heads/master
Commit: f5599152a715a987f36d7606ba3a967b7d297501
Parents: b9a9d27
Author: Gilles <erans@apache.org>
Authored: Wed Sep 5 00:59:20 2018 +0200
Committer: Gilles <erans@apache.org>
Committed: Wed Sep 5 00:59:20 2018 +0200

----------------------------------------------------------------------
 .../distribution/ZigguratNormalizedGaussianSampler.java | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f5599152/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 48d4342..cbd5e06 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
@@ -125,6 +125,7 @@ public class ZigguratNormalizedGaussianSampler
         x = hz * W[iz];
         if (iz == 0) {
             // Base strip.
+            // This branch is called about 5.7624515E-4 times per sample.
             do {
                 y = -Math.log(rng.nextDouble());
                 x = -Math.log(rng.nextDouble()) * ONE_OVER_R;
@@ -134,16 +135,13 @@ public class ZigguratNormalizedGaussianSampler
             return hz > 0 ? out : -out;
         } else {
             // Wedge of other strips.
+            // This branch is called about 0.027323 times per sample.
             if (F[iz] + rng.nextDouble() * (F[iz - 1] - F[iz]) < gauss(x)) {
                 return x;
             } else {
-                final long hzNew = rng.nextLong();
-                final int izNew = (int) (hzNew & LAST);
-                if (Math.abs(hzNew) < K[izNew]) {
-                    return hzNew * W[izNew];
-                } else {
-                    return fix(hzNew, izNew);
-                }
+                // Try again.
+                // This branch is called about 0.012362 times per sample.
+                return sample();
             }
         }
     }


Mime
View raw message