reset (RandStream)

Reset random number stream

Syntax

reset(s)
reset(s,seed)

Description

reset(s) resets the generator for the random stream, s, to the internal state corresponding to its seed. This is similar to clearing s and recreating it using RandStream(Type,...), except that reset does not set the stream's NormalTransform, Antithetic, and FullPrecision properties to their original values.

reset(s,seed) resets the generator for the random stream, s, to the internal state corresponding to seed (the seed value), and it updates the seed property of s. The value of seed must be an integer between 0 and 232 − 1. Resetting a stream's seed can invalidate independence with other streams.

Note

Resetting a stream should be used primarily for reproducing results.

Examples

Example 1

Reset a random number stream to its initial state. This does not create a random number stream, it simply resets the stream:

stream = RandStream('twister','Seed',0)
stream = 

mt19937ar random stream
             Seed: 0
  NormalTransform: Ziggurat
reset(stream);
stream.Seed
ans =

           0

Example 2

Reset a random number stream using a specific seed:

stream = RandStream('twister','Seed',0)
stream = 

mt19937ar random stream
             Seed: 0
  NormalTransform: Ziggurat
reset(stream,1);
stream.Seed
ans =

           1