Package jsl.utilities.random.rng
Class MarseRobertsLCG
- java.lang.Object
-
- jsl.utilities.random.rng.MarseRobertsLCG
-
- All Implemented Interfaces:
java.util.function.DoubleSupplier
,GetAntitheticValueIfc
,RandU01Ifc
public class MarseRobertsLCG extends java.lang.Object implements RandU01Ifc
-
-
Constructor Summary
Constructors Constructor Description MarseRobertsLCG()
Constructs an instance of the generator using stream 1MarseRobertsLCG(int stream)
Constructs an instance of the generator using the supplied stream
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getAntitheticValue()
Returns the antithetic of the previous U(0,1) i.e.int
getDefaultSeed(int stream)
Gets the seed associated with the supplied stream.double
getPrevU01()
The previous U(0,1) generated (returned) by randU01()int
getSeed()
Returns the current value for the seedint
getStream()
Gets the last stream specified by setStream().double
randU01()
Returns a U(0,1) using the current value of the seed.void
setSeed(int seed)
Sets the current seed to the supplied integer, causing the generator to start generating using the supplied seed.void
setStream(int stream)
Changes the current stream for the generator.-
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.RandU01Ifc
asDoubleStream, getAsDouble
-
-
-
-
Method Detail
-
setSeed
public final void setSeed(int seed)
Sets the current seed to the supplied integer, causing the generator to start generating using the supplied seed. After using this method the method getStream() will return the last stream used by the generator not necessarily the stream associated with the supplied stream- Parameters:
seed
-
-
getSeed
public final int getSeed()
Returns the current value for the seed- Returns:
-
getDefaultSeed
public final int getDefaultSeed(int stream)
Gets the seed associated with the supplied stream. The stream must be in [1,100]- Parameters:
stream
-- Returns:
-
setStream
public final void setStream(int stream)
Changes the current stream for the generator. Causes the generator to start generating from the beginning of the specified stream- Parameters:
stream
-
-
getStream
public final int getStream()
Gets the last stream specified by setStream(). Directly using setSeed() may cause the seed not to correspond to this returned stream- Returns:
-
randU01
public final double randU01()
Returns a U(0,1) using the current value of the seed. The current seed is updated after this call- Specified by:
randU01
in interfaceRandU01Ifc
- Returns:
- the random number
-
getPrevU01
public final double getPrevU01()
The previous U(0,1) generated (returned) by randU01()- Specified by:
getPrevU01
in interfaceRandU01Ifc
- Returns:
-
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:
-
-