public class RandomVariateGen
extends java.lang.Object
nextDouble method, 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 created
RandomStream and
Distribution
objects, or by invoking the constructor of a subclass.
By default, all random variates will be generated via
inversion by calling the
inverseF
method 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 and Description |
|---|
RandomVariateGen(RandomStream s,
Distribution dist)
Creates a new random variate generator from the
distribution dist, using stream s.
|
| Modifier and Type | Method and Description |
|---|---|
Distribution |
getDistribution()
Returns the
Distribution used by this generator. |
RandomStream |
getStream()
Returns the
RandomStream used by this generator. |
void |
nextArrayOfDouble(double[] v,
int start,
int n)
Generates n random numbers from the continuous distribution
contained in this object.
|
double |
nextDouble()
Generates a random number from the continuous distribution
contained in this object.
|
void |
setStream(RandomStream stream)
Sets the
RandomStream used by this generator to stream. |
public RandomVariateGen(RandomStream s, Distribution dist)
s - random stream used for generating uniformsdist - continuous distribution object of the generated valuespublic double nextDouble()
inverseF
method of the distribution object.
Alternative generating methods are provided in subclasses.public void nextArrayOfDouble(double[] v,
int start,
int n)
nextDouble() n
times, but one can override it in subclasses for better efficiency.v - array in which the variates will be storedstart - starting index, in v, of the new variatesn - number of variates to generatepublic RandomStream getStream()
RandomStream used by this generator.public void setStream(RandomStream stream)
RandomStream used by this generator to stream.public Distribution getDistribution()
Distribution used by this generator.To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.