RandStream.create
Create statistically independent random number streams
Syntax
Description
creates a single random stream that uses the uniform pseudorandom number generator algorithm
specified by s
= RandStream.create(gentype
)gentype
. RandStream.list
returns all possible values for gentype
, or
see Creating and Controlling a Random Number Stream for details on generator algorithms. The RandStream
function is a more concise alternative when you need to create a
single stream.
[s1,s2,...] = RandStream.create(
creates gentype
,'NumStreams',n)n
random number streams. The streams are independent in a
pseudorandom sense. The streams are not necessarily independent from streams created at
other times.
Note
Not all generator types support multiple streams. Use either the multiplicative
lagged Fibonacci generator ('mlfg6331_64'
) or the combined multiple
recursive generator ('mrg32k3a'
) to create multiple streams.
[___] = RandStream.create(
controls creation of the stream using one or more gentype
,Name,Value
)Name,Value
pairs.
Examples
Input Arguments
Tips
Typically, you call RandStream.create
once to create multiple
independent streams in a single pass or at the beginning of a MATLAB session. For example, you can create three independent streams by using
[s1,s2,s3] = RandStream.create('mrg32k3a','NumStreams',3)
.
Alternatively, you can create each stream from a separate call to
RandStream.create
, but you must specify the appropriate values for
gentype
, 'NumStreams'
, 'Seed'
, and
'StreamIndices'
to ensure their independence:
Specify the same values for
gentype
,'NumStreams'
, and'Seed'
in each case.Specify a different value for
'StreamIndices'
each time. All values should be between1
and the value of'NumStreams'
.
For example, create two independent streams by using s1 =
RandStream.create('mrg32k3a','NumStreams',5,'Seed',0,'StreamIndices',1)
and
s2 =
RandStream.create('mrg32k3a','NumStreams',5,'Seed',0,'StreamIndices',2)
.
Version History
Introduced in R2008b