Package jsl.utilities.random.rvariable
Class ConstantRV
- java.lang.Object
-
- jsl.utilities.random.rvariable.ConstantRV
-
- All Implemented Interfaces:
java.util.function.DoubleSupplier,GetNameIfc,GetValueIfc,IdentityIfc,PreviousValueIfc,RandomIfc,GetRandomNumberStreamIfc,RNStreamControlIfc,SetRandomNumberStreamIfc,NewAntitheticInstanceIfc,RVariableIfc,SampleIfc
- Direct Known Subclasses:
VConstantRV
public class ConstantRV extends java.lang.Object implements RVariableIfc, IdentityIfc
Allows a constant to pretend to be a random variable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jsl.utilities.random.rvariable.RVariableIfc
RVariableIfc.RVType
-
-
Field Summary
Fields Modifier and Type Field Description protected doublemyValuestatic ConstantRVONEA constant to represent one for sharingstatic ConstantRVPOSITIVE_INFINITYA constant to represent positive infinity for sharingstatic ConstantRVTWOA constant to represent two for sharingstatic ConstantRVZEROA constant to represent zero for sharing
-
Constructor Summary
Constructors Constructor Description ConstantRV(double value)
-
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 substreambooleangetAntitheticOption()intgetId()java.lang.StringgetName()doublegetPreviousValue()Gets the previous number from the sequence of valuesRNStreamIfcgetRandomNumberStream()static RVControlsmakeControls()The keys are "value", the default value is 1.0RVariableIfcnewAntitheticInstance()ConstantRVnewInstance()ConstantRVnewInstance(RNStreamIfc rng)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 substreamdoublesample()voidsetAntitheticOption(boolean flag)Tells the stream to start producing antithetic variatesvoidsetName(java.lang.String str)Sets the namevoidsetRandomNumberStream(RNStreamIfc stream)Sets the underlying random number streamjava.lang.StringtoString()-
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, getValue
-
Methods inherited from interface jsl.utilities.random.rng.SetRandomNumberStreamIfc
setRandomNumberStream
-
-
-
-
Field Detail
-
ZERO
public static final ConstantRV ZERO
A constant to represent zero for sharing
-
ONE
public static final ConstantRV ONE
A constant to represent one for sharing
-
TWO
public static final ConstantRV TWO
A constant to represent two for sharing
-
POSITIVE_INFINITY
public static final ConstantRV POSITIVE_INFINITY
A constant to represent positive infinity for sharing
-
myValue
protected double myValue
-
-
Method Detail
-
newInstance
public final ConstantRV newInstance(RNStreamIfc rng)
- Specified by:
newInstancein interfaceRVariableIfc- Parameters:
rng- the RNStreamIfc to use- Returns:
- a new instance with same parameter value
-
newInstance
public final ConstantRV newInstance()
- Specified by:
newInstancein interfaceRVariableIfc- Returns:
- a new instance with same parameter value
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getName
public final java.lang.String getName()
- Specified by:
getNamein interfaceGetNameIfc- Returns:
- a string representing the name of the object
-
getId
public final int getId()
- Specified by:
getIdin interfaceIdentityIfc- Returns:
- an int representing the id of the object
-
setName
public final void setName(java.lang.String str)
Sets the name- Parameters:
str- The name as a string.
-
sample
public final double sample()
-
resetStartStream
public final 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 final void resetStartSubstream()
Description copied from interface:RNStreamControlIfcResets the position of the RNG at the start of the current substream- Specified by:
resetStartSubstreamin interfaceRNStreamControlIfc
-
advanceToNextSubstream
public final void advanceToNextSubstream()
Description copied from interface:RNStreamControlIfcPositions the RNG at the beginning of its next substream- Specified by:
advanceToNextSubstreamin interfaceRNStreamControlIfc
-
setAntitheticOption
public final 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
-
getPreviousValue
public double getPreviousValue()
Description copied from interface:PreviousValueIfcGets the previous number from the sequence of values- Specified by:
getPreviousValuein interfacePreviousValueIfc- Returns:
- a double representing the last value in the sequence
-
newAntitheticInstance
public final RVariableIfc newAntitheticInstance()
- Specified by:
newAntitheticInstancein interfaceNewAntitheticInstanceIfc- Returns:
- a new instance with same parameter value, but that has antithetic variates
-
makeControls
public static RVControls makeControls()
The keys are "value", the default value is 1.0- Returns:
- a control for Constant random variables
-
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
-
-