Main Content

reset

Reset random number stream

Description

example

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

example

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

Reset Stream to Its Initial State

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

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

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

           0

Reset Stream Using Specific Seed

Reset a random number stream using a specific seed.

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

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

           1

Input Arguments

collapse all

Random number stream, specified as a RandStream or a parallel.gpu.RandStream (Parallel Computing Toolbox) object.

Random number seed, specified as a nonnegative integer. The value of seed must be an integer between 0 and 232 − 1.

Introduced in R2008b