public class DiscreteUniformVariate extends RandomVariateBase implements DiscreteRandomVariate
minimum = smallest possible value (integer).maximum = largest possible value (integer).| Modifier and Type | Field and Description |
|---|---|
protected int |
maximum
The largest value of this RandomVariate.
|
protected int |
minimum
The smallest value of this RandomVariate.
|
private int |
range
The difference between the min and max, precalculated for performance.
|
rng| Constructor and Description |
|---|
DiscreteUniformVariate()
Creates a new DiscreteUniformVariate with min and max both zero.
|
| Modifier and Type | Method and Description |
|---|---|
double |
generate()
Generates and returns the next value, cast to a double.
|
int |
generateInt()
Generates and returns the next value.
|
int |
getMaximum()
Returns the largest value.
|
int |
getMinimum()
Returns the smallest value.
|
java.lang.Object[] |
getParameters()
Returns an array containing the minimum and maximum as Intergers.
|
void |
setMaximum(int max)
Sets the largest value.
|
void |
setMinimum(int min)
Sets the smallest value.
|
void |
setParameters(java.lang.Object... params)
Sets the minimum and maximum values for this RandomVariate.
|
java.lang.String |
toString()
Returns a String containing the name of this variate with the
minimum and maximum values.
|
getRandomNumber, setRandomNumberclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetRandomNumber, setRandomNumberprotected int minimum
protected int maximum
private int range
public DiscreteUniformVariate()
public void setParameters(java.lang.Object... params)
setParameters in interface RandomVariateparams - A two element array with the minimum and maximum values
as Integers.java.lang.IllegalArgumentException - If the array does not contain 2 elements
or the elements are not Integers.public java.lang.Object[] getParameters()
getParameters in interface RandomVariatepublic double generate()
generate in interface RandomVariatepublic java.lang.String toString()
toString in class java.lang.Objectpublic int generateInt()
generateInt in interface DiscreteRandomVariatepublic void setMinimum(int min)
min - smallest possible valuepublic void setMaximum(int max)
max - largest possible valuepublic int getMaximum()
public int getMinimum()