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[]myCDFprotected java.util.List<T>myElementsprotected RNStreamIfcmyRNG
-
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 voidadvanceToNextSubstream()Positions the RNG at the beginning of its next substreambooleancontains(java.lang.Object arg0)booleancontainsAll(java.util.Collection<?> arg0)booleangetAntitheticOption()double[]getCDF()java.util.List<T>getList()TgetRandomElement()Returns an element randomly selected from the listRNStreamIfcgetRandomNumberStream()intindexOf(java.lang.Object arg0)booleanisEmpty()static voidmain(java.lang.String[] args)voidresetStartStream()The resetStartStream method will position the RNG at the beginning of its stream.voidresetStartSubstream()Resets the position of the RNG at the start of the current substreamvoidsetAntitheticOption(boolean flag)Tells the stream to start producing antithetic variatesvoidsetRandomNumberStream(RNStreamIfc stream)Sets the underlying random number streamintsize()-
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:RElementIfcReturns an element randomly selected from the list- Specified by:
getRandomElementin interfaceRElementIfc<T>- Returns:
- a randomly selected element from the list
-
advanceToNextSubstream
public void advanceToNextSubstream()
Description copied from interface:RNStreamControlIfcPositions the RNG at the beginning of its next substream- Specified by:
advanceToNextSubstreamin interfaceRNStreamControlIfc
-
resetStartStream
public void resetStartStream()
Description copied from interface:RNStreamControlIfcThe 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:
resetStartStreamin interfaceRNStreamControlIfc
-
resetStartSubstream
public void resetStartSubstream()
Description copied from interface:RNStreamControlIfcResets the position of the RNG at the start of the current substream- Specified by:
resetStartSubstreamin interfaceRNStreamControlIfc
-
setAntitheticOption
public void setAntitheticOption(boolean flag)
Description copied from interface:RNStreamControlIfcTells the stream to start producing antithetic variates- Specified by:
setAntitheticOptionin interfaceRNStreamControlIfc- Parameters:
flag- true means that it produces antithetic variates.
-
getAntitheticOption
public final boolean getAntitheticOption()
- Specified by:
getAntitheticOptionin 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:
getRandomNumberStreamin interfaceGetRandomNumberStreamIfc- Returns:
- the random number stream reference
-
setRandomNumberStream
public void setRandomNumberStream(RNStreamIfc stream)
Description copied from interface:SetRandomNumberStreamIfcSets the underlying random number stream- Specified by:
setRandomNumberStreamin interfaceSetRandomNumberStreamIfc- Parameters:
stream- the reference to the random number stream, must not be null
-
-