public class BernoulliVariate extends RandomVariateBase implements DiscreteRandomVariate
probability
= P{X = 1} or the probability of "success"
in a single trial.Modifier and Type | Field and Description |
---|---|
private double |
probability
The probability of success.
|
rng
Constructor and Description |
---|
BernoulliVariate()
Creates new BernoulliVariate with a probability of success of 0.
|
Modifier and Type | Method and Description |
---|---|
double |
generate()
Generate the next value cast to
double . |
int |
generateInt()
Generate the next value as an integer (0 or 1)
|
java.lang.Object[] |
getParameters()
Returns a single element array containing the probability of success
wrapped as an Object.
|
double |
getProbability()
Returns the value of the probability.
|
void |
setParameters(java.lang.Object... params)
Set the probability of success to the value of the element of the given
array
|
void |
setProbability(double probability)
Sets the probability of success.
|
java.lang.String |
toString()
Returns the name of the distribution and the value of the probability.
|
getRandomNumber, setRandomNumber
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getRandomNumber, setRandomNumber
public BernoulliVariate()
public int generateInt()
generateInt
in interface DiscreteRandomVariate
public double generate()
double
.generate
in interface RandomVariate
public java.lang.Object[] getParameters()
getParameters
in interface RandomVariate
public void setParameters(java.lang.Object... params)
setParameters
in interface RandomVariate
params
- The probability of '1', as a double in the range [0,1].java.lang.IllegalArgumentException
- If the array does not contain exactly
one element or the element is not a Number with a value between 0 and 1
inclusive.public void setProbability(double probability)
probability
- The probability of 1, in range [0,1]java.lang.IllegalArgumentException
- If the argument is not between 0 and 1
inclusive.public double getProbability()
public java.lang.String toString()
toString
in class java.lang.Object