This class implements a random variate generator that returns a constant value. More...
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. | |
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.
| 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.
| 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.
| v | array in which the variates will be stored |
| start | starting index, in v, of the new variates |
| n | number of variates to generate |
Reimplemented from umontreal.ssj.randvar.RandomVariateGen.
Definition at line 54 of file ConstantGen.java.
| 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.
Reimplemented from umontreal.ssj.randvar.RandomVariateGen.
Definition at line 49 of file ConstantGen.java.