Package jsl.utilities.random.robj
Class DEmpiricalList<T>
- java.lang.Object
-
- jsl.utilities.random.robj.DEmpiricalList<T>
-
- Type Parameters:
T
- the type of elements in the list
- All Implemented Interfaces:
GetRandomNumberStreamIfc
,RNStreamControlIfc
,SetRandomNumberStreamIfc
,RElementIfc<T>
public class DEmpiricalList<T> extends java.lang.Object implements RElementIfc<T>
Randomly selects the elements in the list according to a supplied CDF across the items
-
-
Field Summary
Fields Modifier and Type Field Description protected double[]
myCDF
protected java.util.List<T>
myElements
protected RNStreamIfc
myRNG
-
Constructor Summary
Constructors Constructor Description DEmpiricalList(java.util.List<T> elements, double[] cdf)
DEmpiricalList(java.util.List<T> elements, double[] cdf, RNStreamIfc rng)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
advanceToNextSubstream()
Positions the RNG at the beginning of its next substreamboolean
contains(java.lang.Object arg0)
boolean
containsAll(java.util.Collection<?> arg0)
boolean
getAntitheticOption()
double[]
getCDF()
java.util.List<T>
getList()
T
getRandomElement()
Returns an element randomly selected from the listRNStreamIfc
getRandomNumberStream()
int
indexOf(java.lang.Object arg0)
boolean
isEmpty()
static void
main(java.lang.String[] args)
void
resetStartStream()
The resetStartStream method will position the RNG at the beginning of its stream.void
resetStartSubstream()
Resets the position of the RNG at the start of the current substreamvoid
setAntitheticOption(boolean flag)
Tells the stream to start producing antithetic variatesvoid
setRandomNumberStream(RNStreamIfc stream)
Sets the underlying random number streamint
size()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsl.utilities.random.rng.GetRandomNumberStreamIfc
getStreamNumber
-
Methods inherited from interface jsl.utilities.random.rng.SetRandomNumberStreamIfc
setRandomNumberStream
-
-
-
-
Field Detail
-
myElements
protected final java.util.List<T> myElements
-
myCDF
protected final double[] myCDF
-
myRNG
protected RNStreamIfc myRNG
-
-
Constructor Detail
-
DEmpiricalList
public DEmpiricalList(java.util.List<T> elements, double[] cdf)
- Parameters:
elements
- the list of elements, must not be nullcdf
- an array holding the cumulative probabilities across the elements in the list
-
DEmpiricalList
public DEmpiricalList(java.util.List<T> elements, double[] cdf, RNStreamIfc rng)
- Parameters:
elements
- the list of elements, must not be nullcdf
- an array holding the cumulative probabilities across the elements in the listrng
- the underlying random number stream to use for randomness
-
-
Method Detail
-
getCDF
public double[] getCDF()
- Returns:
- a copy of the underlying CDF array
-
getRandomElement
public T getRandomElement()
Description copied from interface:RElementIfc
Returns an element randomly selected from the list- Specified by:
getRandomElement
in interfaceRElementIfc<T>
- Returns:
- a randomly selected element from the list
-
advanceToNextSubstream
public void advanceToNextSubstream()
Description copied from interface:RNStreamControlIfc
Positions the RNG at the beginning of its next substream- Specified by:
advanceToNextSubstream
in interfaceRNStreamControlIfc
-
resetStartStream
public void resetStartStream()
Description copied from interface:RNStreamControlIfc
The resetStartStream method will position the RNG at the beginning of its stream. This is the same location in the stream as assigned when the RNG was created and initialized.- Specified by:
resetStartStream
in interfaceRNStreamControlIfc
-
resetStartSubstream
public void resetStartSubstream()
Description copied from interface:RNStreamControlIfc
Resets the position of the RNG at the start of the current substream- Specified by:
resetStartSubstream
in interfaceRNStreamControlIfc
-
setAntitheticOption
public void setAntitheticOption(boolean flag)
Description copied from interface:RNStreamControlIfc
Tells the stream to start producing antithetic variates- Specified by:
setAntitheticOption
in interfaceRNStreamControlIfc
- Parameters:
flag
- true means that it produces antithetic variates.
-
getAntitheticOption
public final boolean getAntitheticOption()
- Specified by:
getAntitheticOption
in interfaceRNStreamControlIfc
- Returns:
- true means on
-
contains
public final boolean contains(java.lang.Object arg0)
-
containsAll
public final boolean containsAll(java.util.Collection<?> arg0)
-
indexOf
public final int indexOf(java.lang.Object arg0)
-
isEmpty
public final boolean isEmpty()
-
size
public final int size()
-
getList
public final java.util.List<T> getList()
-
main
public static void main(java.lang.String[] args)
-
getRandomNumberStream
public RNStreamIfc getRandomNumberStream()
- Specified by:
getRandomNumberStream
in interfaceGetRandomNumberStreamIfc
- Returns:
- the random number stream reference
-
setRandomNumberStream
public void setRandomNumberStream(RNStreamIfc stream)
Description copied from interface:SetRandomNumberStreamIfc
Sets the underlying random number stream- Specified by:
setRandomNumberStream
in interfaceSetRandomNumberStreamIfc
- Parameters:
stream
- the reference to the random number stream, must not be null
-
-