public abstract class RandomStreamBase extends java.lang.Object implements CloneableRandomStream, java.io.Serializable
If the nextValue already generates numbers with a precision of
53-bits 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.
RandomStreamBase and its subclasses are implementing the Serializable interface.
Each class has a serial number wich represent the class version.
For instance 70510 means that the last change was the 10th May 2007.
| Constructor and Description |
|---|
RandomStreamBase() |
| Modifier and Type | Method and Description |
|---|---|
RandomStreamBase |
clone()
Clones the current generator and return its copy.
|
java.lang.String |
formatState()
Deprecated.
|
java.lang.String |
formatStateFull()
Deprecated.
|
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 uniform 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: Ng is computed, and
Cg and Bg are set to Ng.
|
abstract void |
resetStartStream()
Reinitializes the stream to its initial state Ig:
Cg and Bg are set to Ig.
|
abstract void |
resetStartSubstream()
Reinitializes the stream to the beginning of its current
substream: Cg is set to Bg.
|
abstract java.lang.String |
toString()
Returns a string containing the current state of this stream.
|
public abstract void resetStartStream()
RandomStreamresetStartStream in interface RandomStreampublic abstract void resetStartSubstream()
RandomStreamresetStartSubstream in interface RandomStreampublic abstract void resetNextSubstream()
RandomStreamresetNextSubstream in interface RandomStreampublic abstract java.lang.String toString()
RandomStreamtoString in interface RandomStreamtoString in class java.lang.Objectpublic 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.
The generators programmed in SSJ never return the values 0 or 1.nextDouble in interface RandomStreampublic void nextArrayOfDouble(double[] u,
int start,
int n)
nextArrayOfDouble in interface RandomStreamu - 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 RandomStreami - the smallest possible returned integerj - the largest possible returned integerpublic void nextArrayOfInt(int i,
int j,
int[] u,
int start,
int n)
nextArrayOfInt in interface RandomStreami - 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 u@Deprecated public java.lang.String formatState()
@Deprecated public java.lang.String formatStateFull()
public RandomStreamBase clone()
clone in interface CloneableRandomStreamclone in class java.lang.ObjectTo submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.