SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | Protected Attributes | List of all members
RandomVariateGen Class Reference

This is the base class for all random variate generators over the real line. More...

Inheritance diagram for RandomVariateGen:
[legend]
Collaboration diagram for RandomVariateGen:
[legend]

Public Member Functions

 RandomVariateGen (RandomStream s, Distribution dist)
 Creates a new random variate generator from the distribution dist, using stream s. More...
 
double nextDouble ()
 Generates a random number from the continuous distribution contained in this object. More...
 
void nextArrayOfDouble (double[] v, int start, int n)
 Generates n random numbers from the continuous distribution contained in this object. More...
 
double [] nextArrayOfDouble (int n)
 Generates n random numbers from the continuous distribution contained in this object, and returns them in a new array of size n. More...
 
RandomStream getStream ()
 Returns the umontreal.ssj.rng.RandomStream used by this generator. More...
 
void setStream (RandomStream stream)
 Sets the umontreal.ssj.rng.RandomStream used by this generator to stream.
 
Distribution getDistribution ()
 Returns the umontreal.ssj.probdist.Distribution used by this generator. More...
 
String toString ()
 Returns a String containing information about the current generator.
 

Protected Attributes

RandomStream stream
 
Distribution dist
 

Detailed Description

This is the base class for all random variate generators over the real line.

It specifies the signature of the 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 umontreal.ssj.rng.RandomStream and umontreal.ssj.probdist.Distribution objects, or by invoking the constructor of a subclass. By default, all random variates will be generated via inversion by calling the umontreal.ssj.probdist.Distribution.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 & Destructor Documentation

◆ RandomVariateGen()

Creates a new random variate generator from the distribution dist, using stream s.

Parameters
srandom stream used for generating uniforms
distcontinuous distribution object of the generated values

Member Function Documentation

◆ getDistribution()

Distribution getDistribution ( )

Returns the umontreal.ssj.probdist.Distribution used by this generator.

Returns
the distribution associated to that object

◆ getStream()

RandomStream getStream ( )

Returns the umontreal.ssj.rng.RandomStream used by this generator.

Returns
the stream associated to this object

◆ nextArrayOfDouble() [1/2]

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 calls nextDouble() n times, but one can override it in subclasses for better efficiency.

Parameters
varray in which the variates will be stored
startstarting index, in v, of the new variates
nnumber of variates to generate

◆ nextArrayOfDouble() [2/2]

double [] nextArrayOfDouble ( int  n)

Generates n random numbers from the continuous distribution contained in this object, and returns them in a new array of size n.

By default, this method calls nextDouble() n times, but one can override it in subclasses for better efficiency.

Parameters
nnumber of variates to generate
Returns
a new array with the generated numbers

◆ nextDouble()

double nextDouble ( )

Generates a random number from the continuous distribution contained in this object.

By default, this method uses inversion by calling the umontreal.ssj.probdist.ContinuousDistribution.inverseF method of the distribution object. Alternative generating methods are provided in subclasses.

Returns
the generated value

The documentation for this class was generated from the following file: