reset (RandStream)
Returns a random stream to its initial state, or to a new seed.
Category: Mathematics > Random Number Generation
Syntax
reset(s)
Restores stream s to the state it had when it was created or last seeded.
reset(s, seed)
Reinitializes s with a new seed.
Description
reset makes a stream repeat itself: after it, the same sequence of numbers comes out again. It changes s in place because a RandStream is a handle object.
To reset the global stream, use rng('default') or reset(RandStream.getGlobalStream).
Input arguments
s- A
RandStreamobject. seed- Nonnegative integer seed.
Example
Replaying a sequence
s = RandStream('mt19937ar', 'Seed', 1);
a = rand(s, 1, 2);
reset(s)
b = rand(s, 1, 2);
isequal(a, b)
reset(s, 2)
rand(s, 1, 1)
Output
ans = logical
1
ans = 0.4360