
SSJ V. 1.2.5. 

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object umontreal.iro.lecuyer.rng.RandomStreamBase
public abstract class RandomStreamBase
This class provides a convenient foundation on which RNGs can be built. It implements all the methods which do not depend directly on the generator itself, but only on its output, which is to be defined by implementing the abstract method nextValue. In the present class, all methods returning random numbers directly or indirectly (nextDouble, nextArrayOfDouble, nextInt and nextArrayOfInt) call nextValue. Thus, to define a subclass that implements a RNG, it suffices to implement nextValue, in addition to the reset... and toString methods. Of course, the other methods may also be overridden for improved efficiency.
If the nextValue already generates numbers with a precision of
53bits or higher, then nextDouble
can be overridden to improve
the performance. The mechanism for increasing the precision assumes that
nextValue returns at least 29 bits of precision, in which case
the higher precision numbers will have roughly 52 bits of precision.
This mechanism was designed primarily for RNGs that return numbers with
around 30 to 32 bits of precision.
Constructor Summary  

RandomStreamBase()

Method Summary  

String 
formatState()
Deprecated: use the toString method. 
String 
formatStateFull()
Eliminated: use the toStringFull method. 
void 
increasedPrecision(boolean incp)
After calling this method with incp = true, each call to the RNG (direct or indirect) for this stream will return a uniform random number with more bits of precision than what is returned by nextValue, and will advance the state of the stream by 2 steps instead of 1 (i.e., nextValue will be called twice for each random number). 
void 
nextArrayOfDouble(double[] u,
int start,
int n)
Calls nextDouble n times to fill the array u. 
void 
nextArrayOfInt(int i,
int j,
int[] u,
int start,
int n)
Calls nextInt n times to fill the array u. 
double 
nextDouble()
Returns a random number between 0 and 1 from the stream. 
int 
nextInt(int i,
int j)
Calls nextDouble once to create one integer between i and j. 
abstract void 
resetNextSubstream()
Reinitializes the stream to the beginning of its next substream: N_{g} is computed, and C_{g} and B_{g} are set to N_{g}. 
abstract void 
resetStartStream()
Reinitializes the stream to its initial state I_{g}: C_{g} and B_{g} are set to I_{g}. 
abstract void 
resetStartSubstream()
Reinitializes the stream to the beginning of its current substream: C_{g} is set to B_{g}. 
abstract String 
toString()
Returns a string containing the current state of this stream. 
Methods inherited from class java.lang.Object 

equals, getClass, hashCode, notify, notifyAll, wait, wait, wait 
Constructor Detail 

public RandomStreamBase()
Method Detail 

public abstract void resetStartStream()
RandomStream
resetStartStream
in interface RandomStream
public abstract void resetStartSubstream()
RandomStream
resetStartSubstream
in interface RandomStream
public abstract void resetNextSubstream()
RandomStream
resetNextSubstream
in interface RandomStream
public abstract String toString()
RandomStream
toString
in interface RandomStream
toString
in class Object
public void increasedPrecision(boolean incp)
More precisely, if s is a stream of a subclass of RandomStreamBase, when the precision has been increased, the instruction ``u = s.nextDouble()'', is equivalent to ``u = (s.nextValue() + s.nextValue()*fact) % 1.0'' where the constant fact is equal to 2^{24}. This also applies when calling nextDouble indirectly (e.g., via nextInt, etc.). By default, or if this method is called again with incp = false, each call to nextDouble for this stream advances the state by 1 step and returns the same number as nextValue.
incp
 if the generator will be set to high precision modepublic double nextDouble()
increasedPrecision
.
nextDouble
in interface RandomStream
public void nextArrayOfDouble(double[] u, int start, int n)
nextArrayOfDouble
in interface RandomStream
u
 the array in which the numbers will be storedstart
 the first index of u to be usedn
 the number of random numbers to put in upublic int nextInt(int i, int j)
nextInt
in interface RandomStream
i
 the smallest possible returned integerj
 the largest possible returned integer
public void nextArrayOfInt(int i, int j, int[] u, int start, int n)
nextArrayOfInt
in interface RandomStream
i
 the smallest possible integer to put in uj
 the largest possible integer to put in uu
 the array in which the numbers will be storedstart
 the first index of u to be usedn
 the number of random numbers to put in upublic String formatState()
public String formatStateFull()

SSJ V. 1.2.5. 

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 