Main Content

RandStream.getGlobalStream

R2026b

Get current global random number stream

Description

stream = RandStream.getGlobalStream returns the current 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, rand draws one value from the global stream for each output value.

  • To generate random integers, randi draws one value from the global stream for each output value and applies a simple transformation.

  • To generate normally distributed random numbers, randn draws one or more values from the global stream for each output value and applies normal transformation algorithm specified in the NormalTransform property of stream.

  • To generate a random permutation of integers, randperm draws values from the global stream and applies a permutation algorithm. The number of values drawn depends on the syntax used to call randperm.

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.

Extended Capabilities

expand all

Version History

Introduced in R2011a