Package jsl.utilities.random.rng
Class RNStreamFactory.RNStream
- java.lang.Object
-
- jsl.utilities.random.rng.RNStreamFactory.RNStream
-
- All Implemented Interfaces:
java.util.function.DoubleSupplier
,GetNameIfc
,IdentityIfc
,GetAntitheticStreamIfc
,GetAntitheticValueIfc
,RandU01Ifc
,RNStreamControlIfc
,RNStreamIfc
,RNStreamNewInstanceIfc
- Enclosing class:
- RNStreamFactory
public class RNStreamFactory.RNStream extends java.lang.Object implements IdentityIfc, RNStreamIfc, RNStreamNewInstanceIfc, GetAntitheticStreamIfc
Instances of RNStream are what is made by the factory. Each created stream should be 2 to 127 2^127 steps ahead of the last stream created.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
advanceToNextSubstream()
Positions the RNG at the beginning of its next substreamboolean
getAntitheticOption()
double
getAntitheticValue()
Returns the antithetic value of the previous valueint
getId()
java.lang.String
getName()
double
getPrevU01()
The previous U(0,1) generated (returned) by randU01()long[]
getStartSubStreamSeed()
Returns the seed for the start of the substreamlong[]
getState()
Returns the current state C_g of this stream.RNStreamFactory.RNStream
newAntitheticInstance()
RNStreamFactory.RNStream
newAntitheticInstance(java.lang.String name)
RNStreamFactory.RNStream
newInstance()
Returns a copy of the stream with exactly the same stateRNStreamFactory.RNStream
newInstance(java.lang.String name)
Returns a copy of the stream that has exactly the same stateint
randInt(int i, int j)
Returns a (pseudo)random number from the discrete uniform distribution over the integers {i, i + 1, .double
randU01()
Returns a pseudo-random uniformly distributed numbervoid
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 option)
Tells the stream to start producing antithetic variatesvoid
setName(java.lang.String str)
Sets the namejava.lang.String
toString()
-
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.RandU01Ifc
asDoubleStream, getAsDouble
-
-
-
-
Method Detail
-
newInstance
public RNStreamFactory.RNStream newInstance()
Description copied from interface:RNStreamNewInstanceIfc
Returns a copy of the stream with exactly the same state- Specified by:
newInstance
in interfaceRNStreamNewInstanceIfc
- Returns:
- Returns a copy of the stream with exactly the same state
-
newInstance
public RNStreamFactory.RNStream newInstance(java.lang.String name)
Description copied from interface:RNStreamNewInstanceIfc
Returns a copy of the stream that has exactly the same state- Specified by:
newInstance
in interfaceRNStreamNewInstanceIfc
- Parameters:
name
- the name of the new instance- Returns:
- Returns a copy of the stream with exactly the same state
-
newAntitheticInstance
public RNStreamFactory.RNStream newAntitheticInstance()
- Specified by:
newAntitheticInstance
in interfaceGetAntitheticStreamIfc
- Returns:
- a copy of the stream that produces antithetic value
-
newAntitheticInstance
public RNStreamFactory.RNStream newAntitheticInstance(java.lang.String name)
- Specified by:
newAntitheticInstance
in interfaceGetAntitheticStreamIfc
- Parameters:
name
- the name of the antithetic instance- Returns:
- a copy of the stream that produces antithetic value
-
getName
public final java.lang.String getName()
- Specified by:
getName
in interfaceGetNameIfc
- Returns:
- a string representing the name of the object
-
getId
public final int getId()
- Specified by:
getId
in 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.
-
resetStartStream
public final 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 final 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
-
advanceToNextSubstream
public final void advanceToNextSubstream()
Description copied from interface:RNStreamControlIfc
Positions the RNG at the beginning of its next substream- Specified by:
advanceToNextSubstream
in interfaceRNStreamControlIfc
-
getStartSubStreamSeed
public final long[] getStartSubStreamSeed()
Returns the seed for the start of the substream- Returns:
- the seed for the start of the substream
-
setAntitheticOption
public final void setAntitheticOption(boolean option)
Description copied from interface:RNStreamControlIfc
Tells the stream to start producing antithetic variates- Specified by:
setAntitheticOption
in interfaceRNStreamControlIfc
- Parameters:
option
- true means that it produces antithetic variates.
-
getAntitheticOption
public final boolean getAntitheticOption()
- Specified by:
getAntitheticOption
in interfaceRNStreamControlIfc
- Returns:
- true means on
-
getState
public final long[] getState()
Returns the current state C_g of this stream. This is a vector of 6 integers. This method is convenient if we want to save the state for subsequent use.- Returns:
- the current state of the generator
-
randU01
public final double randU01()
Description copied from interface:RandU01Ifc
Returns a pseudo-random uniformly distributed number- Specified by:
randU01
in interfaceRandU01Ifc
- Returns:
- the random number
-
getPrevU01
public final double getPrevU01()
Description copied from interface:RandU01Ifc
The previous U(0,1) generated (returned) by randU01()- Specified by:
getPrevU01
in interfaceRandU01Ifc
- Returns:
- previous U(0,1) generated (returned) by randU01()
-
getAntitheticValue
public final double getAntitheticValue()
Description copied from interface:GetAntitheticValueIfc
Returns the antithetic value of the previous value- Specified by:
getAntitheticValue
in interfaceGetAntitheticValueIfc
- Returns:
- the antithetic value of the previous value
-
randInt
public final int randInt(int i, int j)
Description copied from interface:RNStreamIfc
Returns a (pseudo)random number from the discrete uniform distribution over the integers {i, i + 1, . . . , j }, using this stream. Calls randU01 once.- Specified by:
randInt
in interfaceRNStreamIfc
- Parameters:
i
- start of rangej
- end of range- Returns:
- The integer pseudo random number
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-