Code covered by the BSD License  

Highlights from
Random Number Streams

Be the first to rate this file! 3 Downloads (last 30 days) File Size: 3.83 KB File ID: #6445

Random Number Streams

by Peter Perkins

 

01 Dec 2004 (Updated 18 Jun 2009)

"Independent" streams of pseudorandom numbers.

| Watch this File

File Information
Description

NOTE: Beginning in release R2008b, MATLAB includes support for random number streams. The code here is not as flexible, and uses some deprecated constructs, and is not recommended or needed for versions of MATLAB newer than R2008a.

These files provide (pseudo)Random Number Generators (RNGs) that are separate from any other calls to other MATLAB RNG functions. Create as many as you need, and they act "independently". That is, calls to one do not affect the state of the others.

Chances are, you do not need to use these. They do not make random values "more random" or "more independent". But they do have uses in certain kinds of simulation modelling work.

Two versions:

* Both versions keep track of their own state vectors internally.

* The first version sets rand and randn to its internal state, calls the appropriate RNG function, and resets rand and randn, each time it's called.

* The second version maintains an internal buffer of random values, and does the above only when the buffer runs short.

The difference is that the second version trades memory overhead for time overhead, and is perhaps more appropriate for users whose simulations dictate getting random values one at a time.

By default, the RNG streams are all initialized to the same zero'th state, meaning they are perfectly correlated if they stay in sync. You'll want to avoid that by initializing to different states.

MATLAB release MATLAB 7.0.1 (R14SP1)
Other requirements More flexible if you have the Statistics Toolbox, but does not require it.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
02 Jun 2009

Added note to description about support for random streams in MATLAB beginning in R2008b.

03 Jun 2009

Clarified description.

12 Jun 2009

Cleaned up file header information.

18 Jun 2009

Added copyright.

Tag Activity for this File
Tag Applied By Date/Time
statistics Peter Perkins 22 Oct 2008 07:37:01
probability Peter Perkins 22 Oct 2008 07:37:01
random stream Peter Perkins 22 Oct 2008 07:37:01
pseudo Peter Perkins 22 Oct 2008 07:37:01
rngs Peter Perkins 22 Oct 2008 07:37:01

Contact us at files@mathworks.com