RandStream.setGlobalStream
R2026bSet global random number stream
Description
sets the specified random number stream as the global stream that the prevstream = RandStream.setGlobalStream(stream)rand, randi, and randn functions draw values from. The function returns the previous global
random number stream.
rand, randi, randn, and randperm all rely on the same stream of uniform random numbers, known as the
global stream.
To generate uniform random numbers strictly between 0 and 1,
randdraws one value from the global stream for each output value.To generate random integers,
randidraws one value from the global stream for each output value and applies a simple transformation.To generate normally distributed random numbers,
randndraws one or more values from the global stream for each output value and applies normal transformation algorithm specified in theNormalTransformproperty ofstream.To generate a random permutation of integers,
randpermdraws values from the global stream and applies a permutation algorithm. The number of values drawn depends on the syntax used to callrandperm.
You can also specify an individual random number stream from which
rand, randi, randn, and
randperm draw values by creating a RandStream object and passing it as the first input argument.
Note
The rng function can be a simpler alternative
for controlling the global stream.
Input Arguments
Output Arguments
Extended Capabilities
Version History
Introduced in R2011a