Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

reset (RandStream) - Reset random stream

Class

@RandStream

Syntax

reset(s)
reset(s,seed)

Description

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

reset(s,seed) resets the generator for the random stream s to the initial internal state corresponding to the seed seed. Resetting a stream's seed can invalidate independence with other streams.

Examples

  1. Create a random stream object.

    s=RandStream('mt19937ar')
  2. Make it the default stream.

    RandStream.setDefaultStream(s)
  3. Reset the stream object you just created and generate 5 uniform random values using the rand method.

    rand(s,1,5)
    
    ans =
    
        0.3631    0.4048    0.1490    0.9438    0.1247
    
  4. Reset the stream.

    reset(s)
  5. Generate the same 5 random values from the default stream.

    rand(s,1,5)
    
    ans =
    
        0.3631    0.4048    0.1490    0.9438    0.1247

See Also

@RandStream

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS