You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2018/01/11 11:42:21 UTC
[4/8] commons-rng git commit: RNG-43: Use new class.
RNG-43: Use new class.
Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/c76bd300
Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/c76bd300
Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/c76bd300
Branch: refs/heads/master
Commit: c76bd300351e1e6e2a15a1ae2b1015a1b979d679
Parents: adcf0c5
Author: Gilles <er...@apache.org>
Authored: Wed Jan 10 17:32:39 2018 +0100
Committer: Gilles <er...@apache.org>
Committed: Wed Jan 10 17:32:39 2018 +0100
----------------------------------------------------------------------
.../distribution/BoxMullerLogNormalSampler.java | 37 +++++---------------
1 file changed, 8 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/c76bd300/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerLogNormalSampler.java
----------------------------------------------------------------------
diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerLogNormalSampler.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerLogNormalSampler.java
index 354b8d4..1db0b7c 100644
--- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerLogNormalSampler.java
+++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/BoxMullerLogNormalSampler.java
@@ -19,42 +19,21 @@ package org.apache.commons.rng.sampling.distribution;
import org.apache.commons.rng.UniformRandomProvider;
/**
- * <a href="https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform">
- * Box-Muller algorithm</a> for sampling from a Log normal distribution.
+ * Sampling from a <a href="https://en.wikipedia.org/wiki/Log-normal_distribution">
+ * log-normal distribution</a>.
+ * Uses {@link BoxMullerNormalizedGaussianSampler} as the underlying sampler.
*/
public class BoxMullerLogNormalSampler
- extends SamplerBase
- implements ContinuousSampler {
- /** Scale. */
- private final double scale;
- /** Shape. */
- private final double shape;
- /** Gaussian sampling. */
- private final NormalizedGaussianSampler gaussian;
-
+ extends LogNormalSampler {
/**
* @param rng Generator of uniformly distributed random numbers.
- * @param scale Scale of the Log normal distribution.
- * @param shape Shape of the Log normal distribution.
+ * @param scale Scale of the log-normal distribution.
+ * @param shape Shape of the log-normal distribution.
*/
public BoxMullerLogNormalSampler(UniformRandomProvider rng,
double scale,
double shape) {
- super(null); // Not used.
- this.scale = scale;
- this.shape = shape;
- gaussian = new BoxMullerNormalizedGaussianSampler(rng);
- }
-
- /** {@inheritDoc} */
- @Override
- public double sample() {
- return Math.exp(scale + shape * gaussian.sample());
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString() {
- return "Box-Muller Log Normal [" + gaussian.toString() + "]";
+ super(new BoxMullerNormalizedGaussianSampler(rng),
+ scale, shape);
}
}