SSJ  3.2.1 Stochastic Simulation in Java
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...

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 ( RandomStream s, Distribution dist )

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

Parameters
 s random stream used for generating uniforms dist continuous distribution object of the generated values

## Member Function Documentation

 Distribution getDistribution ( )

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

Returns
the distribution associated to that object
 RandomStream getStream ( )

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

Returns
the stream associated to this object
 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
 v array in which the variates will be stored start starting index, in v, of the new variates n number of variates to generate
 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:
• RandomVariateGen.java