Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

create (RandStream) - Create random number streams

Class

@RandStream

Syntax

[s1,s2,...] = RandStream.create('gentype','NumStreams',n)
s = RandStream.create('gentype')
[ ... ] = RandStream.create(..., 'PARAM1',val1, 'PARAM2',val2, ...)

Description

[s1,s2,...] = RandStream.create('gentype','NumStreams',n) creates n random number streams that use the uniform pseudorandom number generator algorithm specified by gentype. The streams are independent in a pseudorandom sense. The streams are not necessarily independent from streams created at other times. RandStream.list returns all possible values for gentype.

s = RandStream.create('gentype') creates a single random stream.

[ ... ] = RandStream.create(..., 'PARAM1',val1, 'PARAM2',val2, ...) allows you to specify optional parameter name or value pairs to control creation of the stream(s). The parameters are:

NumStreamsTotal number of streams of this type that will be created across sessions or labs. Default is 1.
StreamIndicesStream indices that should be created in this call. Default is 1:N, where N is the value given with the 'NumStreams' parameter.
SeedNonnegative scalar integer with which to initialize all streams. Default is 0. Seeds must be an integer between 0 and .
RandnAlgAlgorithm that will be used by randn(S, ...) to generate normal pseudorandom values. Options are 'Ziggurat', 'Polar', or 'Inversion'.
CellOutputLogical flag indicating whether or not to return the stream objects as elements of a cell array. Default is false.

Examples

Create three independent streams.

[s1,s2,s3] = RandStream.create('mrg32k3a','NumStreams',3);
r1 = rand(s1,100000,1); r2 = rand(s2,100000,1); r3 = rand(s3,100000,1);
corrcoef([r1,r2,r3])

Create one stream from a set of three independent streams and designate it as the default stream.

s2 = RandStream.create('mrg32k3a','NumStreams',3,'StreamIndices',2);
RandStream.setDefaultStream(s2);

See Also

@RandStream, RandStream (RandStream), list (RandStream), getDefaultStream (RandStream), setDefaultStream (RandStream), rand (RandStream), randi (RandStream), randn (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