Main Content

RandStream.getGlobalStream

Get current global random number stream

Description

stream = RandStream.getGlobalStream returns the current global random number stream.

rand, randi, and randn all rely on the same stream of uniform pseudorandom numbers, known as the global stream. rand draws one value from that stream to generate each uniform value it returns. randi draws one uniform value from that stream to generate each integer value it returns. And randn draws one or more uniform values to generate each normal value it returns. Note that you can also specify a specific random stream from which rand, randi, and randn draw values by creating a RandStream object and passing it as the first input argument.

Note

The rng function is a shorter alternative for many common uses of RandStream.getGlobalStream.

Introduced in R2011a