SSJ
V. 2.6.

umontreal.iro.lecuyer.randvar
Class ConstantGen

java.lang.Object
  extended by umontreal.iro.lecuyer.randvar.RandomVariateGen
      extended by umontreal.iro.lecuyer.randvar.ConstantGen

public class ConstantGen
extends RandomVariateGen

This class implements a random variate generator that returns a constant value. Its mass function is

p(x) = 1,        for x = c,

and p(x) = 0 elsewhere.


Constructor Summary
ConstantGen(double val)
          Constructs a new constant generator returning the given value val.
 
Method Summary
 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.
 
Methods inherited from class umontreal.iro.lecuyer.randvar.RandomVariateGen
getDistribution, getStream, setStream, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConstantGen

public ConstantGen(double val)
Constructs a new constant generator returning the given value val.

Method Detail

nextDouble

public double nextDouble()
Description copied from class: RandomVariateGen
Generates a random number from the continuous distribution contained in this object. By default, this method uses inversion by calling the inverseF method of the distribution object. Alternative generating methods are provided in subclasses.

Overrides:
nextDouble in class RandomVariateGen
Returns:
the generated value

nextArrayOfDouble

public void nextArrayOfDouble(double[] v,
                              int start,
                              int n)
Description copied from class: RandomVariateGen
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.

Overrides:
nextArrayOfDouble in class RandomVariateGen
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

SSJ
V. 2.6.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.