SSJ
V. 1.2.5.

umontreal.iro.lecuyer.randvar
Class TriangularGen

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

public class TriangularGen
extends RandomVariateGen

This class implements random variate generators for the triangular distribution. Its density is

f (x) = 2(x - a)/[(b - a)(m - a)]          for a <= x <= m,
f (x) = 2(b - x)/[(b - a)(b - m)]          for m <= x <= b,
f (x) = 0          elsewhere,

where a <= m <= b (see, e.g.,).

The (non-static) nextDouble method simply calls inverseF on the distribution.


Constructor Summary
TriangularGen(RandomStream s, TriangularDist dist)
          Creates a new generator for the triangular distribution dist and stream s.
 
Method Summary
 double nextDouble()
          Generates a random number from the continuous distribution contained in this object.
static double nextDouble(RandomStream s, double a, double b, double m)
          Generates a new variate from the triangular distribution with parameters a = a, b = b and m = m and stream s, using inversion.
 
Methods inherited from class umontreal.iro.lecuyer.randvar.RandomVariateGen
getDistribution, getStream, nextArrayOfDouble, setStream
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TriangularGen

public TriangularGen(RandomStream s,
                     TriangularDist dist)
Creates a new generator for the triangular distribution dist and stream s.

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

nextDouble

public static double nextDouble(RandomStream s,
                                double a,
                                double b,
                                double m)
Generates a new variate from the triangular distribution with parameters a = a, b = b and m = m and stream s, using inversion.


SSJ
V. 1.2.5.

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