Utility
Class Triangular

java.lang.Object
  |
  +--Utility.RandomNumber
        |
        +--Utility.Triangular

public class Triangular
extends RandomNumber

Triangular is used to generate random variables from the triangular distribution.

This is a continuous distribution.

Tests Performed
1000 samples were generated and the means and variances were examined. Subjectively, they seemed correct. A goodness of fit test was performed with 100 samples and 10 intervals. It succeeded about 19/20 times.


Constructor Summary
Triangular(double left, double center, double right)
          Triangular constructor.
 
Method Summary
 double sampleDouble()
          Generate a random double from the triangular distribution.
 int sampleInt()
          The sampleInt function should not be called for this continuous distribution.
 
Methods inherited from class Utility.RandomNumber
goodnessOfFitTest, goodnessOfFitTest, randomMixer, resetRandomMixer, sample01
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Triangular

public Triangular(double left,
                  double center,
                  double right)
Triangular constructor. The left, right and center points along the x-axis characterize the triangular distribution.

Parameters:
left - The leftmost endpoint
center - The center point of the triangle (x-axis pos not height.
right - The rightmost endpoint
Method Detail

sampleDouble

public double sampleDouble()
Generate a random double from the triangular distribution.

Overrides:
sampleDouble in class RandomNumber
Returns:
A double from the triangular distribution. The output is gauranteed to be between the left and right endpoints.
See Also:
Triangular(double, double, double)

sampleInt

public int sampleInt()
The sampleInt function should not be called for this continuous distribution.

Overrides:
sampleInt in class RandomNumber