SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.randvar.ConstantGen Class Reference

This class implements a random variate generator that returns a constant value. More...

Inheritance diagram for umontreal.ssj.randvar.ConstantGen:
umontreal.ssj.randvar.RandomVariateGen

Public Member Functions

 ConstantGen (double val)
 Constructs a new constant generator returning the given value val.
double nextDouble ()
 Generates a random number from the continuous distribution contained in this object.
void nextArrayOfDouble (double[] v, int start, int n)
 Generates n random numbers from the continuous distribution contained in this object.
Public Member Functions inherited from umontreal.ssj.randvar.RandomVariateGen
 RandomVariateGen (RandomStream s, Distribution dist)
 Creates a new random variate generator from the distribution dist, using stream s.
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.
RandomStream getStream ()
 Returns the umontreal.ssj.rng.RandomStream used by this generator.
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.
String toString ()
 Returns a String containing information about the current generator.

Detailed Description

This class implements a random variate generator that returns a constant value.

Its mass function is

\[ p(x) = \left\{\begin{array}{ll} 1, & \qquad\mbox{for } x = c, \\ 0, & \qquad\mbox{elsewhere. } \end{array}\right. \tag{randcons} \]

Definition at line 38 of file ConstantGen.java.

Constructor & Destructor Documentation

◆ ConstantGen()

umontreal.ssj.randvar.ConstantGen.ConstantGen ( double val)

Constructs a new constant generator returning the given value val.

Definition at line 44 of file ConstantGen.java.

Member Function Documentation

◆ nextArrayOfDouble()

void umontreal.ssj.randvar.ConstantGen.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

Reimplemented from umontreal.ssj.randvar.RandomVariateGen.

Definition at line 54 of file ConstantGen.java.

◆ nextDouble()

double umontreal.ssj.randvar.ConstantGen.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

Reimplemented from umontreal.ssj.randvar.RandomVariateGen.

Definition at line 49 of file ConstantGen.java.


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