s = RandStream(type)
s = RandStream(type, Name, Value)
x = rand(s, ...)
x = randn(s, ...)
x = randi(s, ...)
p = randperm(s, n)
[s1, s2, ...] = RandStream.create(type, 'NumStreams', n)
RandStream creates a mutable random number stream. Supported stream properties include Type, Seed, NumStreams, StreamIndex, State, Substream, NormalTransform, Antithetic, and FullPrecision.
Type, Seed, NumStreams, and StreamIndex are read-only after construction. State, Substream, NormalTransform, Antithetic, and FullPrecision can be assigned.
Supported generator types include mt19937ar, twister64, dsfmt19937, mrg32k3a, mlfg6331_64, philox4x32_10, threefry4x64_20, pcg64dxsm (alias pcg), and xoshiro256pp (alias xoshiro).
pcg64dxsm is a 64-bit permuted congruential generator with double xor-shift multiply and xoshiro256pp a xor-shift-rotate generator with 256-bit state and double addition. Their default NormalTransform is Inversion. With FullPrecision set to false, they generate each double from 32 random bits instead of 53, which is faster; two streams that differ only by FullPrecision generate different sequences.
Static methods include create, list, getGlobalStream, and setGlobalStream.
s = RandStream('mt19937ar', 'Seed', 4);
x = rand(s, 1, 3);
reset(s);
y = rand(s, 1, 3)
s = RandStream('pcg64dxsm', 'Seed', 1, 'FullPrecision', false);
s.NormalTransform
x = rand(s, 1, 4)
| Version | Description |
|---|---|
| 2.0.0 | New generator types: pcg64dxsm and xoshiro256pp |