Documentation

reset (RandStream)

Reset random number stream

Class

RandStream

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 clearingsand recreating it usingRandStream(Type,...), except thatresetdoes not set the stream'sNormalTransform,Antithetic, andFullPrecisionproperties to their original values.

reset(s,seed)resets the generator for the random stream,s, to the internal state corresponding toseed(the seed value), and it updates theseedproperty ofs. The value ofseedmust 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

Was this topic helpful?