Repository: commons-rng Updated Branches: refs/heads/master 5b88619b7 -> 3b3f19beb
Formatting. Use "final". Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/3b3f19be Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/3b3f19be Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/3b3f19be Branch: refs/heads/master Commit: 3b3f19beb89ef86b9fb0a8f98684054687100793 Parents: 5b88619 Author: Gilles <er...@apache.org> Authored: Fri Dec 8 15:49:19 2017 +0100 Committer: Gilles <er...@apache.org> Committed: Fri Dec 8 15:49:19 2017 +0100 ---------------------------------------------------------------------- .../ZigguratNormalizedGaussianSampler.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-rng/blob/3b3f19be/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 ea9eb04..5a47b2a 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 @@ -76,7 +76,7 @@ public class ZigguratNormalizedGaussianSampler FN[127] = e; for (int i = 126; i >= 1; i--){ - e = Math.exp(-0.5 *dn * dn); + e = Math.exp(-0.5 * dn * dn); dn = Math.sqrt(-2 * Math.log(vn / dn + e)); KN[i+1] = (int) ((dn / tn) * m); tn = dn; @@ -95,9 +95,9 @@ public class ZigguratNormalizedGaussianSampler /** {@inheritDoc} */ @Override public double sample() { - int j = nextInt(); - int i = j & 127; - return (j < KN[i]) ? j * WN[i] : nfix(j,i); + final int j = nextInt(); + final int i = j & 127; + return (j < KN[i]) ? j * WN[i] : nfix(j, i); } /** @@ -107,7 +107,8 @@ public class ZigguratNormalizedGaussianSampler * @param iz Corresponding to hz cell's number. * @return the requested random value. */ - private double nfix(int hz, int iz) { + private double nfix(int hz, + int iz) { // The start of the right tail. final double r = 3.442619855899; @@ -116,7 +117,7 @@ public class ZigguratNormalizedGaussianSampler double y; while (true) { - uni = .5 + hz * .2328306e-9; + uni = 0.5 + hz * 0.2328306e-9; x = hz * WN[iz]; // iz == 0 handles the base strip. if (iz == 0) { @@ -124,7 +125,7 @@ public class ZigguratNormalizedGaussianSampler do { y = -Math.log(uni); x = y * 0.2904764; - uni = .5 + nextInt() * .2328306e-9; + uni = 0.5 + nextInt() * 0.2328306e-9; } while (y + y < x * x); return (hz > 0) ? r + x : -r - x; }