public class Geometric_64Variate extends java.lang.Object implements DiscreteRandomVariate
Uses simkit.util.Math64.log() function for replicability on 64-bit platforms.
Modifier and Type | Field and Description |
---|---|
private double |
multiplier
A value pre-calculated from p.
|
private double |
p
The probability of success for a single trial.
|
private RandomNumber |
rng
The supporting RandomNumber instance.
|
Constructor and Description |
---|
Geometric_64Variate()
Creates a new GeometricVariate with the default supporting RandomNumber.
|
Modifier and Type | Method and Description |
---|---|
double |
generate()
Generates the next value cast to a
double . |
int |
generateInt()
Generates the next value as an int.
|
double |
getP() |
java.lang.Object[] |
getParameters()
Returns a single element array containing
p . |
RandomNumber |
getRandomNumber()
Returns the instance of the supporting RandomNumber.
|
void |
setP(double prob) |
void |
setParameters(java.lang.Object... params)
Sets the probability of success for a single trial for this GammaVariate.
|
void |
setRandomNumber(RandomNumber rng)
Sets the supporting RandomNumber instance
|
java.lang.String |
toString()
Returns a String containing the name of this distribution and the value of
p . |
private double p
private double multiplier
private RandomNumber rng
public Geometric_64Variate()
p
must be set prior to generating.public RandomNumber getRandomNumber()
getRandomNumber
in interface RandomVariate
public void setRandomNumber(RandomNumber rng)
setRandomNumber
in interface RandomVariate
rng
- The RandomNumber instance supporting the generating algorithmpublic java.lang.Object[] getParameters()
p
.getParameters
in interface RandomVariate
public void setParameters(java.lang.Object... params)
setParameters
in interface RandomVariate
params
- A single element array containing p
as a Number.java.lang.IllegalArgumentException
- If the array does not contain a single element,
or if the given probability is not between 0 and 1
inclusive.java.lang.ClassCastException
- If the element cannot be cast to a Number.public int generateInt()
generateInt
in interface DiscreteRandomVariate
public double generate()
double
.generate
in interface RandomVariate
public void setP(double prob)
prob
- the probability of success of a single trial to the given value.java.lang.IllegalArgumentException
- If the given probability is not between
0 and 1 inclusive.public double getP()
public java.lang.String toString()
p
.toString
in class java.lang.Object