Package jsl.utilities.random.rng
Class RNStreamFactoryDepracated.RNStream
- java.lang.Object
-
- jsl.utilities.random.rng.RNStreamFactoryDepracated.RNStream
-
- All Implemented Interfaces:
java.util.function.DoubleSupplier
,GetNameIfc
,IdentityIfc
,GetAntitheticStreamIfc
,GetAntitheticValueIfc
,RandU01Ifc
,RNStreamControlIfc
,RNStreamIfc
,RNStreamNewInstanceIfc
- Enclosing class:
- RNStreamFactoryDepracated
public class RNStreamFactoryDepracated.RNStream extends java.lang.Object implements RNStreamIfc, IdentityIfc, RNStreamNewInstanceIfc, GetAntitheticStreamIfc
A concrete implementation of a random number stream (RngIfc)
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
advanceState(int e, int c)
Advances the state by n steps (see below for the meaning of n), without modifying the states of the other streams or the values of Bg and Ig in the current object.void
advanceToNextSubstream()
Reinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.boolean
getAntitheticOption()
Returns whether or not the antithetic option is on (true) or off (false)double
getAntitheticValue()
Returns the antithetic of the previous U(0,1) i.e.int
getId()
java.lang.String
getName()
double
getPrevU01()
The previous U(0,1) generated (returned) by randU01()long[]
getStartStreamSeed()
Returns the seed for the start of the streamlong[]
getStartSubStreamSeed()
Returns the seed for the start of the substreamlong[]
getState()
Returns the current state of this stream.void
increasedPrecis(boolean incp)
If incp = true, each RNG call with this stream will now give 53 bits of resolution instead of 32 bits (assuming that the machine follows the IEEE-754 floating-point standard), and will advance the state of the stream by 2 steps instead of 1.RNStreamFactoryDepracated.RNStream
newAntitheticInstance()
RNStreamFactoryDepracated.RNStream
newAntitheticInstance(java.lang.String name)
RNStreamFactoryDepracated.RNStream
newInstance()
Returns a copy of the stream with exactly the same stateRNStreamFactoryDepracated.RNStream
newInstance(java.lang.String name)
Returns a copy of the stream that has exactly the same statevoid
printState()
Prints the current state of this stream.void
printStateFull()
Writes to the standard output the value of all internal variables of this stream: name, anti, Ig, Bg, Cgint
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 U(0, 1) (pseudo)random number, using this stream, after advancing its state by one step.void
resetStartStream()
Reinitializes the stream to its initial state: Cg and Bg are set to Ig.void
resetStartSubstream()
Reinitializes the stream to the beginning of its current substream: Cg is set to Bg.void
setAntitheticOption(boolean a)
If a = true, the stream will now generate antithetic variates.void
setName(java.lang.String str)
Sets the nameboolean
setSeed(long[] seed)
Sets the initial seed Ig of the stream to the vector seed.java.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 RNStreamFactoryDepracated.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 RNStreamFactoryDepracated.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 RNStreamFactoryDepracated.RNStream newAntitheticInstance()
- Specified by:
newAntitheticInstance
in interfaceGetAntitheticStreamIfc
- Returns:
- a copy of the stream that produces antithetic value
-
newAntitheticInstance
public RNStreamFactoryDepracated.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.
-
getStartStreamSeed
public final long[] getStartStreamSeed()
Returns the seed for the start of the stream- Returns:
- the seed for the start of the stream
-
resetStartStream
public final void resetStartStream()
Reinitializes the stream to its initial state: Cg and Bg are set to Ig.- Specified by:
resetStartStream
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
-
resetStartSubstream
public final void resetStartSubstream()
Reinitializes the stream to the beginning of its current substream: Cg is set to Bg.- Specified by:
resetStartSubstream
in interfaceRNStreamControlIfc
-
advanceToNextSubstream
public final void advanceToNextSubstream()
Reinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.- Specified by:
advanceToNextSubstream
in interfaceRNStreamControlIfc
-
setAntitheticOption
public final void setAntitheticOption(boolean a)
If a = true, the stream will now generate antithetic variates.- Specified by:
setAntitheticOption
in interfaceRNStreamControlIfc
- Parameters:
a
- flag to turn on antithetic variates
-
getAntitheticOption
public final boolean getAntitheticOption()
Returns whether or not the antithetic option is on (true) or off (false)- Specified by:
getAntitheticOption
in interfaceRNStreamControlIfc
- Returns:
- whether or not the antithetic option is on (true) or off (false)
-
increasedPrecis
public final void increasedPrecis(boolean incp)
If incp = true, each RNG call with this stream will now give 53 bits of resolution instead of 32 bits (assuming that the machine follows the IEEE-754 floating-point standard), and will advance the state of the stream by 2 steps instead of 1.- Parameters:
incp
- If incp = true, each RNG call with this stream will now give 53 bits of resolution instead of 32 bits
-
advanceState
public final void advanceState(int e, int c)
Advances the state by n steps (see below for the meaning of n), without modifying the states of the other streams or the values of Bg and Ig in the current object. If e >0, then n = 2^e +c; if e < 0, then n = -2^-e + c; and if e = 0, then n = c. Note, c is allowed to take negative values- Parameters:
e
- an integerc
- an integer
-
setSeed
public final boolean setSeed(long[] seed)
Sets the initial seed Ig of the stream to the vector seed. The vector seed should contain valid seed values. The state of the stream is then reset to this initial seed. The states and seeds of the other streams are not modified. As a result, after calling this procedure, the initial seeds of the streams are no longer spaced Z values apart. We discourage the use of this procedure; proper use of Reset is preferable.- Parameters:
seed
- the array of seeds- Returns:
- returns true if the seed is valid
-
getState
public final long[] getState()
Returns the current state of this stream.- Returns:
- An array representing the state
-
printState
public final void printState()
Prints the current state of this stream.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
printStateFull
public final void printStateFull()
Writes to the standard output the value of all internal variables of this stream: name, anti, Ig, Bg, Cg
-
randU01
public final double randU01()
Returns a U(0, 1) (pseudo)random number, using this stream, after advancing its state by one step. Exactly 0.0 or exactly 1.0 will not be generated- Specified by:
randU01
in interfaceRandU01Ifc
- Returns:
- the uniform (0,1) pseudo random number
-
getPrevU01
public final double getPrevU01()
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()
Returns the antithetic of the previous U(0,1) i.e. 1.0 - getPrevU01()- Specified by:
getAntitheticValue
in interfaceGetAntitheticValueIfc
- Returns:
- the antithetic of the previous U(0,1) i.e. 1.0 - getPrevU01()
-
randInt
public final int randInt(int i, int j)
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
-
-