Package jsl.utilities.random.rng
Class RNStreamMakerBU.RNStream
- java.lang.Object
-
- jsl.utilities.random.rng.RNStreamMakerBU.RNStream
-
- All Implemented Interfaces:
java.util.function.DoubleSupplier,GetNameIfc,IdentityIfc,GetAntitheticStreamIfc,GetAntitheticValueIfc,RandU01Ifc,RNStreamControlIfc,RNStreamIfc,RNStreamNewInstanceIfc
- Enclosing class:
- RNStreamMakerBU
public class RNStreamMakerBU.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 voidadvanceToNextSubstream()Positions the RNG at the beginning of its next substreambooleangetAntitheticOption()doublegetAntitheticValue()Returns the antithetic value of the previous valueintgetId()java.lang.StringgetName()doublegetPrevU01()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.RNStreamMakerBU.RNStreamnewAntitheticInstance()RNStreamMakerBU.RNStreamnewAntitheticInstance(java.lang.String name)RNStreamMakerBU.RNStreamnewInstance()Returns a copy of the stream with exactly the same stateRNStreamMakerBU.RNStreamnewInstance(java.lang.String name)Returns a copy of the stream that has exactly the same stateintrandInt(int i, int j)Returns a (pseudo)random number from the discrete uniform distribution over the integers {i, i + 1, .doublerandU01()Returns a pseudo-random uniformly distributed numbervoidresetStartStream()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 option)Tells the stream to start producing antithetic variatesvoidsetName(java.lang.String str)Sets the namejava.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.RandU01Ifc
asDoubleStream, getAsDouble
-
-
-
-
Method Detail
-
newInstance
public RNStreamMakerBU.RNStream newInstance()
Description copied from interface:RNStreamNewInstanceIfcReturns a copy of the stream with exactly the same state- Specified by:
newInstancein interfaceRNStreamNewInstanceIfc- Returns:
- Returns a copy of the stream with exactly the same state
-
newInstance
public RNStreamMakerBU.RNStream newInstance(java.lang.String name)
Description copied from interface:RNStreamNewInstanceIfcReturns a copy of the stream that has exactly the same state- Specified by:
newInstancein interfaceRNStreamNewInstanceIfc- Parameters:
name- the name of the new instance- Returns:
- Returns a copy of the stream with exactly the same state
-
newAntitheticInstance
public RNStreamMakerBU.RNStream newAntitheticInstance()
- Specified by:
newAntitheticInstancein interfaceGetAntitheticStreamIfc- Returns:
- a copy of the stream that produces antithetic value
-
newAntitheticInstance
public RNStreamMakerBU.RNStream newAntitheticInstance(java.lang.String name)
- Specified by:
newAntitheticInstancein 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:
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.
-
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
-
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:RNStreamControlIfcTells the stream to start producing antithetic variates- Specified by:
setAntitheticOptionin interfaceRNStreamControlIfc- Parameters:
option- true means that it produces antithetic variates.
-
getAntitheticOption
public final boolean getAntitheticOption()
- Specified by:
getAntitheticOptionin 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:RandU01IfcReturns a pseudo-random uniformly distributed number- Specified by:
randU01in interfaceRandU01Ifc- Returns:
- the random number
-
getPrevU01
public final double getPrevU01()
Description copied from interface:RandU01IfcThe previous U(0,1) generated (returned) by randU01()- Specified by:
getPrevU01in interfaceRandU01Ifc- Returns:
- previous U(0,1) generated (returned) by randU01()
-
getAntitheticValue
public final double getAntitheticValue()
Description copied from interface:GetAntitheticValueIfcReturns the antithetic value of the previous value- Specified by:
getAntitheticValuein interfaceGetAntitheticValueIfc- Returns:
- the antithetic value of the previous value
-
randInt
public final int randInt(int i, int j)Description copied from interface:RNStreamIfcReturns a (pseudo)random number from the discrete uniform distribution over the integers {i, i + 1, . . . , j }, using this stream. Calls randU01 once.- Specified by:
randIntin interfaceRNStreamIfc- Parameters:
i- start of rangej- end of range- Returns:
- The integer pseudo random number
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-