umontreal.iro.lecuyer.randvar
Class RandomVariateGen
- java.lang.Object
-
- umontreal.iro.lecuyer.randvar.RandomVariateGen
-
- Direct Known Subclasses:
- BetaGen, CauchyGen, ChiGen, ChiSquareGen, ChiSquareNoncentralGen, ExponentialGen, ExtremeValueGen, FatigueLifeGen, FisherFGen, FoldedNormalGen, FrechetGen, GammaGen, GumbelGen, HalfNormalGen, HyperbolicSecantGen, InverseFromDensityGen, InverseGammaGen, InverseGaussianGen, JohnsonSBGen, JohnsonSUGen, KernelDensityGen, LogisticGen, LoglogisticGen, LognormalGen, LognormalSpecialGen, NakagamiGen, NormalGen, NormalInverseGaussianGen, ParetoGen, Pearson5Gen, Pearson6Gen, PowerGen, RandomVariateGenInt, RandomVariateGenWithCache, RayleighGen, StudentGen, TriangularGen, UniformGen, UnuranContinuous, UnuranEmpirical, WeibullGen
public class RandomVariateGen extends java.lang.ObjectThis is the base class for all random variate generators over the real line. It specifies the signature of thenextDoublemethod, which is normally called to generate a real-valued random variate whose distribution has been previously selected. A random variate generator object can be created simply by invoking the constructor of this class with previously createdRandomStreamandDistributionobjects, or by invoking the constructor of a subclass. By default, all random variates will be generated via inversion by calling theinverseFmethod for the distribution, even though this can be inefficient in some cases. For some of the distributions, there are subclasses with special and more efficient methods to generate the random variates.For generating many random variates, creating an object and calling the non-static method is more efficient when the generating algorithm involves a significant setup. When no work is done at setup time, the static methods are usually slightly faster.
-
-
Constructor Summary
Constructors Constructor and Description RandomVariateGen(RandomStream s, Distribution dist)Creates a new random variate generator from the distribution dist, using stream s.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description DistributiongetDistribution()Returns theDistributionused by this generator.RandomStreamgetStream()Returns theRandomStreamused by this generator.voidnextArrayOfDouble(double[] v, int start, int n)Generates n random numbers from the continuous distribution contained in this object.doublenextDouble()Generates a random number from the continuous distribution contained in this object.voidsetStream(RandomStream stream)Sets theRandomStreamused by this generator to stream.java.lang.StringtoString()Returns a String containing information about the current generator.
-
-
-
Constructor Detail
-
RandomVariateGen
public RandomVariateGen(RandomStream s, Distribution dist)
Creates a new random variate generator from the distribution dist, using stream s.- Parameters:
s- random stream used for generating uniformsdist- continuous distribution object of the generated values
-
-
Method Detail
-
nextDouble
public double nextDouble()
Generates a random number from the continuous distribution contained in this object. By default, this method uses inversion by calling theinverseFmethod of the distribution object. Alternative generating methods are provided in subclasses.- Returns:
- the generated value
-
nextArrayOfDouble
public void nextArrayOfDouble(double[] v, int start, int n)Generates n random numbers from the continuous distribution contained in this object. These numbers are stored in the array v, starting from index start. By default, this method callsnextDouble()n times, but one can override it in subclasses for better efficiency.- Parameters:
v- array in which the variates will be storedstart- starting index, in v, of the new variatesn- number of variates to generate
-
getStream
public RandomStream getStream()
Returns theRandomStreamused by this generator.- Returns:
- the stream associated to this object
-
setStream
public void setStream(RandomStream stream)
Sets theRandomStreamused by this generator to stream.
-
getDistribution
public Distribution getDistribution()
Returns theDistributionused by this generator.- Returns:
- the distribution associated to that object
-
toString
public java.lang.String toString()
Returns a String containing information about the current generator.- Overrides:
toStringin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG