com.opttek.optquest
Class COptQuestRandomNumber

java.lang.Object
  extended by com.opttek.optquest.COptQuestRandomNumber

public class COptQuestRandomNumber
extends java.lang.Object

The COptQuestRandomNumber class provides random numbers in different forms such as uniform or triangular.


Constructor Summary
COptQuestRandomNumber()
          Default Constructor - uses a predefined random number seed.
COptQuestRandomNumber(int seed)
          Constructor used to provide the random number seed.
 
Method Summary
 int Discrete01(double oneProbability)
           
 int DiscreteUniform(int min, int max)
           
 int GetNextRandomOrder()
          GetNextRandomOrder() returns the next random integer value set by SetRandomOrderRange().
 double LogNormal(double mean, double stddev)
           
 double Normal(double mean, double stddev)
           
 double Normal01()
           
 int PickBasedOnWeights(double[] weights, int numWeights)
           
 void SetRandomOrderRange(int min, int max)
          SetRandomOrderRange() sets a range from min to max to return the integer values from min to max in a random order.
 void SetSeed(int seed)
          SetSeed() changes the random number seed and resets the random number generator.
 double Triangular(double min, double mostlikely, double max)
          Triangular() returns a random number from a triangular distribution.
 boolean TrueFalse()
           
 boolean TrueFalse(double trueProbability)
           
 double Uniform(double min, double max)
          Uniform() returns a uniform random number from min to max.
 double Uniform01()
          Uniform01() returns a uniform random number from 0.0 to 1.0.
 int UniformInteger(int LowerBound, int UpperBound)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

COptQuestRandomNumber

public COptQuestRandomNumber()
Default Constructor - uses a predefined random number seed.


COptQuestRandomNumber

public COptQuestRandomNumber(int seed)
Constructor used to provide the random number seed.

Parameters:
seed - - random number seed
Method Detail

SetSeed

public void SetSeed(int seed)
SetSeed() changes the random number seed and resets the random number generator.

Parameters:
seed - - random number seed

Triangular

public double Triangular(double min,
                         double mostlikely,
                         double max)
                  throws COptQuestException
Triangular() returns a random number from a triangular distribution.

Parameters:
min - - minimum value
mostlikely - - most likely value
max - - maximum value
Returns:
random number
Throws:
COptQuestException

Uniform01

public double Uniform01()
Uniform01() returns a uniform random number from 0.0 to 1.0.

Returns:
random number

Normal01

public double Normal01()

Normal

public double Normal(double mean,
                     double stddev)

Uniform

public double Uniform(double min,
                      double max)
Uniform() returns a uniform random number from min to max.

Parameters:
min - - minimum value
max - - maximum value
Returns:
random number
Throws:
COptQuestException

Discrete01

public int Discrete01(double oneProbability)

TrueFalse

public boolean TrueFalse(double trueProbability)

TrueFalse

public boolean TrueFalse()

DiscreteUniform

public int DiscreteUniform(int min,
                           int max)

LogNormal

public double LogNormal(double mean,
                        double stddev)

SetRandomOrderRange

public void SetRandomOrderRange(int min,
                                int max)
SetRandomOrderRange() sets a range from min to max to return the integer values from min to max in a random order. Use GetNextRandomOrder() to get the next value.


GetNextRandomOrder

public int GetNextRandomOrder()
GetNextRandomOrder() returns the next random integer value set by SetRandomOrderRange().

Returns:
next random value

UniformInteger

public int UniformInteger(int LowerBound,
                          int UpperBound)

PickBasedOnWeights

public int PickBasedOnWeights(double[] weights,
                              int numWeights)