Package jsl.utilities.random.rvariable
Class DEmpiricalRV
- java.lang.Object
-
- jsl.utilities.random.rvariable.AbstractRVariable
-
- jsl.utilities.random.rvariable.DEmpiricalRV
-
- All Implemented Interfaces:
java.util.function.DoubleSupplier
,GetNameIfc
,GetValueIfc
,IdentityIfc
,PreviousValueIfc
,RandomIfc
,GetRandomNumberStreamIfc
,RNStreamControlIfc
,SetRandomNumberStreamIfc
,NewAntitheticInstanceIfc
,RVariableIfc
,SampleIfc
public final class DEmpiricalRV extends AbstractRVariable
Discrete Empirical Random Variable. Randomly selects from the supplied values in the value array according to the supplied CDF array. The CDF array must have valid probability elements and last element equal to 1. Every element must be greater than or equal to the previous element in the CDF array. That is, monotonically increasing.
-
-
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 DEmpiricalRV(double[] values, double[] cdf)
Randomly selects from the array using the supplied cdfDEmpiricalRV(double[] values, double[] cdf, int streamNum)
Randomly selects from the array using the supplied cdfDEmpiricalRV(double[] values, double[] cdf, RNStreamIfc rng)
Randomly selects from the array using the supplied cdf
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double
generate()
double[]
getCDF()
double[]
getValues()
static RVControls
makeControls()
The keys are "values" with default an array {0.0, 1.0} and key "cdf" with default array {0.5, 1.0}DEmpiricalRV
newInstance(RNStreamIfc rng)
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
-
DEmpiricalRV
public DEmpiricalRV(double[] values, double[] cdf)
Randomly selects from the array using the supplied cdf- Parameters:
values
- array to select fromcdf
- the cumulative probability associated with each element of array
-
DEmpiricalRV
public DEmpiricalRV(double[] values, double[] cdf, int streamNum)
Randomly selects from the array using the supplied cdf- Parameters:
values
- array to select fromcdf
- the cumulative probability associated with each element of arraystreamNum
- the stream number
-
DEmpiricalRV
public DEmpiricalRV(double[] values, double[] cdf, RNStreamIfc rng)
Randomly selects from the array using the supplied cdf- Parameters:
values
- array to select fromcdf
- the cumulative probability associated with each element of arrayrng
- the source of randomness
-
-
Method Detail
-
newInstance
public DEmpiricalRV newInstance(RNStreamIfc rng)
- Parameters:
rng
- the RNStreamIfc to use- Returns:
- a new instance with same parameter value
-
getValues
public double[] getValues()
- Returns:
- the values to select from
-
getCDF
public double[] getCDF()
- Returns:
- the cdf to select with
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
generate
protected double generate()
- Specified by:
generate
in classAbstractRVariable
- Returns:
- the randomly generated variate
-
makeControls
public static RVControls makeControls()
The keys are "values" with default an array {0.0, 1.0} and key "cdf" with default array {0.5, 1.0}- Returns:
- a control for DEmpirical random variables
-
-