SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.random.distribution
Class Gaussian

java.lang.Object
  extended by com.numericalmethod.suanshu.stats.random.distribution.Gaussian
All Implemented Interfaces:
RandomNumberGenerator
Direct Known Subclasses:
StandardGaussian

public class Gaussian
extends java.lang.Object
implements RandomNumberGenerator

Sample pseudo random numbers from the Normal distribution.

See Also:
Wikipedia: Normal distribution

Nested Class Summary
static class Gaussian.Method
          the methods available to sample from the Normal distribution
 
Field Summary
 double mu
          the mean
 double sigma
          the standard deviation
 
Constructor Summary
Gaussian(double mu, double sigma)
          Construct a pseudo-random number generator of a Gaussian distribution using the Box-Muller method.
Gaussian(double mu, double sigma, Gaussian.Method method, RandomNumberGenerator rng)
          Construct a pseudo-random number generator of a Gaussian distribution.
 
Method Summary
 double nextDouble()
          Get the next Gaussian sample.
 void seed(long... seeds)
          Seed the random number generator to produce repeatable sequences.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mu

public final double mu
the mean


sigma

public final double sigma
the standard deviation

Constructor Detail

Gaussian

public Gaussian(double mu,
                double sigma,
                Gaussian.Method method,
                RandomNumberGenerator rng)
Construct a pseudo-random number generator of a Gaussian distribution.

Parameters:
mu - the mean
sigma - the standard deviation
method - the sampling method
rng - a uniform random number generator

Gaussian

public Gaussian(double mu,
                double sigma)
Construct a pseudo-random number generator of a Gaussian distribution using the Box-Muller method.

Parameters:
mu - the mean
sigma - the standard deviation
Method Detail

seed

public void seed(long... seeds)
Description copied from interface: RandomNumberGenerator
Seed the random number generator to produce repeatable sequences.

Specified by:
seed in interface RandomNumberGenerator
Parameters:
seeds - the seeds

nextDouble

public double nextDouble()
Get the next Gaussian sample.

This method is synchronized so that one call generates two random samples.

Specified by:
nextDouble in interface RandomNumberGenerator
Returns:
the next Gaussian sample

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.