Example of use (web site).
Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/f631ab5a Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/f631ab5a Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/f631ab5a Branch: refs/heads/master Commit: f631ab5ae734f1d0c841f146e4234c4fc00f2050 Parents: 55ddfba Author: Gilles <er...@apache.org> Authored: Thu Nov 17 19:01:30 2016 +0100 Committer: Gilles <er...@apache.org> Committed: Thu Nov 17 19:01:30 2016 +0100 ---------------------------------------------------------------------- commons-rng-sampling/src/site/xdoc/index.xml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f631ab5a/commons-rng-sampling/src/site/xdoc/index.xml ---------------------------------------------------------------------- diff --git a/commons-rng-sampling/src/site/xdoc/index.xml b/commons-rng-sampling/src/site/xdoc/index.xml index e4c86fd..78d7a79 100644 --- a/commons-rng-sampling/src/site/xdoc/index.xml +++ b/commons-rng-sampling/src/site/xdoc/index.xml @@ -40,9 +40,20 @@ Example: <source>import org.apache.commons.rng.UniformRandomProvider; -import org.apache.commons.rng.simple.RandomSource; +import org.apache.commons.rng.sampling.distribution.ContinuousSampler; +import org.apache.commons.rng.sampling.distribution.BoxMullerGaussianSampler; - // TODO +public class NormalDeviates { + private final ContinuousSampler normalizedGaussian; + + public NormalDeviates(UniformRandomProvider rng) { + normalizedGaussian = new BoxMullerGaussianSampler(rng, 0, 1); + } + + public double sample(double mean, + double sigma) { + return mean + sigma * normalizedGaussian.sample(); + } } </source> </p>