Package jsl.utilities.random.rvariable
Class BernoulliRV
- java.lang.Object
-
- jsl.utilities.random.rvariable.AbstractRVariable
-
- jsl.utilities.random.rvariable.BernoulliRV
-
- All Implemented Interfaces:
java.util.function.DoubleSupplier
,GetNameIfc
,GetValueIfc
,IdentityIfc
,PreviousValueIfc
,RandomIfc
,GetRandomNumberStreamIfc
,RNStreamControlIfc
,SetRandomNumberStreamIfc
,NewAntitheticInstanceIfc
,RVariableIfc
,SampleIfc
public final class BernoulliRV extends AbstractRVariable
Bernoulli(probability of success) random variable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jsl.utilities.random.rvariable.RVariableIfc
RVariableIfc.RVType
-
-
Field Summary
-
Fields inherited from class jsl.utilities.random.rvariable.AbstractRVariable
myRNStream
-
-
Constructor Summary
Constructors Constructor Description BernoulliRV(double prob)
Uses a new stream from the default provider of streamsBernoulliRV(double prob, int streamNum)
BernoulliRV(double prob, RNStreamIfc stream)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double
generate()
boolean
getBoolean()
Returns a randomly generated boolean according to the Bernoulli distributionboolean[]
getBooleanSample(int n)
Returns a boolean array filled via getBoolean()double
getProbabilityOfSuccess()
Gets the success probabilitystatic RVControls
makeControls()
The key is "ProbOfSuccess", the default value is 0.5BernoulliRV
newInstance(RNStreamIfc stream)
java.lang.String
toString()
-
Methods inherited from class jsl.utilities.random.rvariable.AbstractRVariable
advanceToNextSubstream, getAntitheticOption, getId, getName, getPreviousValue, getRandomNumberStream, getValue, newAntitheticInstance, newInstance, resetStartStream, resetStartSubstream, sample, setAntitheticOption, setName, setPreviousValue, setRandomNumberStream
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jsl.utilities.random.rng.GetRandomNumberStreamIfc
getStreamNumber
-
Methods inherited from interface jsl.utilities.random.rvariable.RVariableIfc
asDoubleStream, getAsDouble, getSumOfValues, newInstance
-
Methods inherited from interface jsl.utilities.random.rng.SetRandomNumberStreamIfc
setRandomNumberStream
-
-
-
-
Constructor Detail
-
BernoulliRV
public BernoulliRV(double prob)
Uses a new stream from the default provider of streams- Parameters:
prob
- the probability, must be in (0,1)
-
BernoulliRV
public BernoulliRV(double prob, int streamNum)
- Parameters:
prob
- the probability, must be in (0,1)streamNum
- the stream number
-
BernoulliRV
public BernoulliRV(double prob, RNStreamIfc stream)
- Parameters:
prob
- the probability, must be in (0,1)stream
- the RNStreamIfc to use
-
-
Method Detail
-
newInstance
public BernoulliRV newInstance(RNStreamIfc stream)
- Parameters:
stream
- the RNStreamIfc to use- Returns:
- a new instance with same parameter value
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getProbabilityOfSuccess
public double getProbabilityOfSuccess()
Gets the success probability- Returns:
- The success probability
-
generate
protected double generate()
- Specified by:
generate
in classAbstractRVariable
- Returns:
- the randomly generated variate
-
getBoolean
public boolean getBoolean()
Returns a randomly generated boolean according to the Bernoulli distribution- Returns:
- a randomly generated boolean
-
getBooleanSample
public boolean[] getBooleanSample(int n)
Returns a boolean array filled via getBoolean()- Parameters:
n
- the generation size, must be at least 1- Returns:
- the array
-
makeControls
public static RVControls makeControls()
The key is "ProbOfSuccess", the default value is 0.5- Returns:
- a control for Bernoulli random variables
-
-