Contains the state of a stream from the present module. It is defined as
typedef struct RngStream_InfoState * RngStream; struct RngStream_InfoState { double Cg[6], Bg[6], Ig[6]; int Anti; int IncPrec; char *name; };The arrays
Ig,Bg, andCgcontain the initial state, the starting point of the current substream, and the current state, respectively. This stream generates antithetic variates ifAnti!= 0. The precision of the output numbers is increased ifIncPrec!= 0.
Sets the initial seed of the package RngStreams to the six integers in the vector seed. This will be the seed (initial state) of the first stream. If this procedure is not called, the default initial seed is
{12345, 12345, 12345, 12345, 12345, 12345}. If it is called, the first 3 values of the seed must all be less thanm_1 = 4294967087, and not all0; and the last 3 values must all be less thanm_2 = 4294944443, and not all0.
Creates and returns a new stream with identifier name, whose state variable is of type
RngStream_InfoState. This procedure reserves space to keep the information relative to theRngStream, initializes its seedIg, setsBgandCgequal toIg, sets its antithetic and precision switches to0. The seedIgis equal to the initial seed of the package given byRngStream_SetPackageSeedif this is the first stream created, otherwise it isZsteps ahead of that of the most recently created stream.
Deletes the stream *pg created previously by
RngStream_CreateStream, and recovers its memory. Otherwise, does nothing.
Reinitializes the stream g to its initial state:
CgandBgare set toIg.
Reinitializes the stream g to the beginning of its current substream:
Cgis set to Bg.
Reinitializes the stream g to the beginning of its next substream:
Ngis computed, andCgandBgare set toNg.
If a != 0, the stream g will start generating antithetic variates, i.e., 1-U instead of U, until this method is called again with a = 0. By default, the streams are created with a = 0.
After calling this procedure with incp != 0, each call (direct or indirect) to
RngStream_RandU01for stream g will advance the state of the stream by 2 steps instead of 1, and will return a number with (roughly) 53 bits of precision instead of 32 bits. More specifically, in the non-antithetic case, when the precision is increased, the instructionx = RngStream_RandU01(g)is equivalent tox = (RngStream_RandU01(g) + RngStream_RandU01(g) * fact) % 1.0where the constantfactis equal to 2^(-24). This also applies when callingRngStream_RandU01indirectly (e.g., by callingRngStream_RandInt, etc.). By default, or if this procedure is called again with incp = 0, each call toRngStream_RandU01for stream g advances the state by 1 step and returns a number with 32 bits of precision.
Sets the initial seed
Igof stream g to the vector seed. This vector must satisfy the same conditions as inRngStream_SetPackageSeed. 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 spacedZvalues apart. We discourage the use of this procedure.
Advances the state of stream g by k values, without modifying the states of other streams (as in
RngStream_SetSeed), nor the values ofBgandIgassociated with this stream. If e > 0, then k = 2^e + c; if e < 0, then k =-2^-e + c; and if e = 0, then k = c. Note: c is allowed to take negative values. We discourage the use of this procedure.
Returns in seed[] the current state
Cgof stream g. This is convenient if we want to save the state for subsequent use.
Prints (to standard output) the current state of stream g.
Prints (to standard output) the name of stream g and the values of all its internal variables.
Returns a (pseudo)random number from the uniform distribution over the interval (0,1), using stream g, after advancing the state by one step. The returned number has 32 bits of precision in the sense that it is always a multiple of 1/(2^32-208), unless
RngStream_IncreasedPrecishas been called for this stream.