Utility
Class Uniform

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

public class Uniform
extends RandomNumber

The Uniform class is used to generate numbers uniformly distributed between the lowerBound and upperBound. These numbers can be either ints or doubles.

This distribution can be both discrete and continuous.

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
Uniform(double lowerBound, double upperBound)
           
Uniform(double lowerBound, int upperBound)
           
Uniform(int lowerBound, double upperBound)
           
Uniform(int lowerBound, int upperBound)
          The Uniform constructor requires the lower and upper bounds and these may be either integers or doubles.
 
Method Summary
 double sampleDouble()
          Draw a random sample.
 int sampleInt()
          Draw a random sample.
 
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

Uniform

public Uniform(int lowerBound,
               int upperBound)
The Uniform constructor requires the lower and upper bounds and these may be either integers or doubles.

Parameters:
lowerBound - The minimum value that random variables will take on.
upperBound - The maximum value that random variables will take on.

Uniform

public Uniform(double lowerBound,
               double upperBound)

Uniform

public Uniform(int lowerBound,
               double upperBound)

Uniform

public Uniform(double lowerBound,
               int upperBound)
Method Detail

sampleInt

public int sampleInt()
Description copied from class: RandomNumber
Draw a random sample. This function should be overridden by all derived classes. The RandomNumber class throws a RuntimeException when this function is invoked, but this function should be used in derived classes that implement discrete distributions.

Overrides:
sampleInt in class RandomNumber
Returns:
A uniformly distributed integer between the lower and upper bounds. lower <= sampleInt() <= upper.
See Also:
Uniform(double, int)

sampleDouble

public double sampleDouble()
Description copied from class: RandomNumber
Draw a random sample. This function should be overridden by all derived classes. The RandomNumber class returns a uniform double in the interval [0,1).

Overrides:
sampleDouble in class RandomNumber
Returns:
A uniformly distributed double between the lower and upper bounds. lower <= sampleInt() < upper.
See Also:
Uniform(double, int)