umontreal.iro.lecuyer.randvar
Class NormalGen
- java.lang.Object
-
- umontreal.iro.lecuyer.randvar.RandomVariateGen
-
- umontreal.iro.lecuyer.randvar.NormalGen
-
- Direct Known Subclasses:
- NormalACRGen, NormalBoxMullerGen, NormalKindermannRamageGen, NormalPolarGen
public class NormalGen extends RandomVariateGen
This class implements methods for generating random variates from the normal distribution N(μ, σ). It has mean μ and variance σ2, where σ > 0. Its density function isf (x) = 1/(2π)1/2σe(x-μ)2/(2σ2)The nextDouble method simply calls inverseF on the distribution.The following table gives the CPU time needed to generate 108 standard normal random variates using the different implementations available in SSJ. The first time is for a generator object (non-static method), and the second time is for the static method where no object is created. These tests were made on a machine with processor AMD Athlon 4000, running Red Hat Linux, with clock speed at 2403 MHz. The static method nextDouble() for NormalBoxMullerGen and NormalPolarGen uses only one number out of two that are generated; thus they are twice slower than the non-static method.
Generator time in seconds time in seconds (object) (static) NormalGen 7.67 7.72 NormalACRGen 4.71 4.76 NormalBoxMullerGen 16.07 31.45 NormalPolarGen 7.31 13.74 NormalKindermannRamageGen 5.38 5.34
-
-
Constructor Summary
Constructors Constructor and Description NormalGen(RandomStream s)Creates a standard normal random variate generator with mean 0 and standard deviation 1, using stream s.NormalGen(RandomStream s, double mu, double sigma)Creates a normal random variate generator with mean mu and standard deviation sigma, using stream s.NormalGen(RandomStream s, NormalDist dist)Creates a random variate generator for the normal distribution dist and stream s.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublegetMu()Returns the parameter μ of this object.doublegetSigma()Returns the parameter σ of this object.static doublenextDouble(RandomStream s, double mu, double sigma)Generates a variate from the normal distribution with parameters μ = mu and σ = sigma, using stream s.-
Methods inherited from class umontreal.iro.lecuyer.randvar.RandomVariateGen
getDistribution, getStream, nextArrayOfDouble, nextDouble, setStream, toString
-
-
-
-
Constructor Detail
-
NormalGen
public NormalGen(RandomStream s, double mu, double sigma)
Creates a normal random variate generator with mean mu and standard deviation sigma, using stream s.
-
NormalGen
public NormalGen(RandomStream s)
Creates a standard normal random variate generator with mean 0 and standard deviation 1, using stream s.
-
NormalGen
public NormalGen(RandomStream s, NormalDist dist)
Creates a random variate generator for the normal distribution dist and stream s.
-
-
Method Detail
-
nextDouble
public static double nextDouble(RandomStream s, double mu, double sigma)
Generates a variate from the normal distribution with parameters μ = mu and σ = sigma, using stream s.
-
getMu
public double getMu()
Returns the parameter μ of this object.
-
getSigma
public double getSigma()
Returns the parameter σ of this object.
-
-
DMelt 3.0 © DataMelt by jWork.ORG