commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [2/4] commons-rng git commit: RNG-36: Performance improvement.
Date Fri, 07 Apr 2017 16:26:42 GMT
RNG-36: Performance improvement.


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

Branch: refs/heads/master
Commit: e591a65643c1383fd72033df6725de3ae7e2b27c
Parents: 4ef78f5
Author: Gilles <erans@apache.org>
Authored: Fri Apr 7 16:03:50 2017 +0200
Committer: Gilles <erans@apache.org>
Committed: Fri Apr 7 16:03:50 2017 +0200

----------------------------------------------------------------------
 .../sampling/distribution/MarsagliaNormalizedGaussianSampler.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rng/blob/e591a656/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 6dc9f2a..6c86452 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
@@ -55,8 +55,7 @@ public class MarsagliaNormalizedGaussianSampler
                 if (r2 < 1) {
                     // Pair (x, y) is within unit circle.
 
-                    final double r = Math.sqrt(r2);
-                    final double alpha = 2 * Math.sqrt(-Math.log(r)) / r;
+                    final double alpha = Math.sqrt(-2 * Math.log(r2) / r2);
 
                     // Return the first element of the generated pair.
                     random = alpha * x;


Mime
View raw message