reset (RandStream)
Reset random number stream
Class
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 clearings
and recreating it usingRandStream(Type,...
), except thatreset
does not set the stream'sNormalTransform
,Antithetic
, andFullPrecision
properties 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 theseed
property ofs
. The value ofseed
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