Docstrings
Auto-generated documentation from the package docstrings.
Abstract types
RandomDataStreams.AbstractRNGStream — Type
AbstractRNGStream is an abstraction for creating RNG objects with non-overlaping random numbers.
RandomDataStreams.AbstractStreamableRNG — Type
AbstractStreamableRNG is a special kind of RNG where one can move between different stream of number that are known to be non-overlapping.
Every concrete subtype implements the same interface, so that code written against AbstractStreamableRNG works with any generator of the package:
| operation | meaning |
|---|---|
next_substream!(rng) | move to the start of the next substream |
reset_substream!(rng) | rewind to the start of the current substream |
reset_stream!(rng) | rewind to the start of the current stream |
advance_state!(rng, e, c) | move by n draws, n given by (e, c); n < 0 moves backwards |
get_state(rng) | current position, in a generator-specific representation |
set_state!(rng, state) | restore a position obtained from get_state |
srand!(rng, seed) | reseed, resetting the stream and substream boundaries |
The unit of advance_state! is one rand(rng) draw, for every generator, so that a jump written against AbstractStreamableRNG means the same thing everywhere. get_state and set_state! are inverses — set_state!(rng, get_state(rng)) leaves rng unchanged — and they move only the current position, never the stream or substream boundaries. The representation returned by get_state differs between families, so generic code should treat it as opaque and only ever hand it back to set_state!.
Streams themselves are produced by an AbstractRNGStream object, which implements the same operations on its side:
| operation | meaning |
|---|---|
Gen() | a generator seeded with the package default, 12345 |
Gen(seed) | seeded with an integer, or with the family's own seed vector |
next_stream!(gen) | the next non-overlapping stream |
next_stream!(gen, n) | the next n of them, as a vector |
srand!(gen, seed) | reset the seed the next next_stream! will use |
get_state(gen) / set_state!(gen, s) | save and restore that seed |
An integer seed is expanded through splitmix64 and folded into whatever the family accepts, so MRG32k3aGen(12345), Xoshiro256ppGen(12345), PhiloxGen(12345) and PCG64Gen(12345) all mean the same kind of thing.
A generator object is a factory, and it is not thread-safe: it rewrites the seed of the next stream on every call, so concurrent calls to next_stream! hand out overlapping streams, silently. Take the streams first, with next_stream!(gen, n), then parallelise over them; streams themselves share no state and need no synchronisation.
Not part of this contract: short_jump! and long_jump!, which are the xoshiro and PCG spelling of a jump by the substream and stream distance. Use next_substream! for portable code. long_jump! has no meaning for a counter-based generator at all, where moving to another stream means taking another key, an operation that belongs to the generator object.
MRG32k3a
RandomDataStreams.MRG32k3a — Type
MRG32k3a() will generate an instance of MRG32k3a with initial seeds DEFAULT_SEED = [ 12345, 12345, 12345, 12345, 12345, 12345 ]
MRG32k3a(x::Vector{Int}) will generate an instance of MRG32k3a with initial seeds x
MRG32k3a(x::Vector{Int}, y::Vector{Int}, z::Vector{Int}) will generate an instance of MRG32k3a with Cg = x, Bg = y and Ig = z
Examples
julia> rng = MRG32k3a();
julia> rand(rng)
0.12701112204657714RandomDataStreams.MRG32k3aGen — Type
An object that generates independent random number streams.
RandomDataStreams.checkseed — Function
checkseed(s::NTuple{N,UInt64}) -> Bool
checkseed(v::AbstractVector{<:Unsigned}) -> Booltrue unless the words are all zero. The all-zero state maps to itself under every xoshiro/xoroshiro transition, so it is the one state the families forbid; there is no other constraint. (The Vector{Int} method is MRG32k3a's, whose seed space is constrained differently.)
MRG63k3a
RandomDataStreams.MRG63k3a — Type
MRG63k3a() will generate an instance of MRG63k3a with initial seeds DEFAULT_SEED63 = [ 12345, 12345, 12345, 12345, 12345, 12345 ]
MRG63k3a(x::Vector{Int}) will generate an instance of MRG63k3a with initial seeds x
MRG63k3a(x::Vector{Int}, y::Vector{Int}, z::Vector{Int}) will generate an instance of MRG63k3a positioned at x, with the substream starting at y and the stream at z. All three are seeds, in the representation get_state returns; the state actually stored runs one step ahead of them (see below).
MRG63k3a is the 64-bit-arithmetic member of L'Ecuyer's (1999) combined MRG family: same structure as MRG32k3a, moduli just under 2^63 instead of 2^32, period ≈ 2^377 instead of 2^191. Its step yields just under 63 random bits, against just under 32 for MRG32k3a, so a machine word costs two steps here and four there.
The state is stored one step ahead of the position, so that a draw returns a pair the previous draw already computed and the processor overlaps the output with the next state. That is internal: seeds, get_state, set_state! and show all speak the same representation as MRG32k3a.
Examples
julia> rng = MRG63k3a();
julia> rand(rng)
0.999964376179128RandomDataStreams.MRG63k3aGen — Type
An object that generates independent MRG63k3a streams, 2^250 numbers apart.
RandomDataStreams.checkseed63 — Function
checkseed63(x::Vector{Int}) -> BoolTrue when x is a valid MRG63k3a seed: six non-negative integers, the first three below m1 = 2^63 - 6645 and not all zero, the last three below m2 = 2^63 - 21129 and not all zero.
Xoshiro / xoroshiro families
RandomDataStreams.LinRNG — Type
LinRNG{N,S} <: AbstractStreamableRNGGeneric xoshiro/xoroshiro generator: state of N 64-bit words and scrambler S ∈ (:plus, :starstar, :plusplus). Holds three checkpoints — current state (Cg), substream start (Bg) and stream start (Ig) — enabling reset_stream!, reset_substream! and anchored jumps. Use the exported aliases (Xoroshiro128p, ..., Xoshiro512pp) instead.
RandomDataStreams.Xoroshiro128p — Type
Xoroshiro128p <: AbstractStreamableRNGxoroshiro128+ (Blackman & Vigna): 128-bit state, period 2^128 - 1, output s0 + s1. Fastest small-state generator for floating-point use; the four lower bits have low linear complexity and it has a very mild Hamming-weight dependency after ~5 TB of output. Suitable only for mild parallelism (2^32 streams x 2^64 substreams).
RandomDataStreams.Xoroshiro128ss — Type
Xoroshiro128ss <: AbstractStreamableRNGxoroshiro128** (Blackman & Vigna): 128-bit state, period 2^128 - 1, all-purpose scrambler (rotl(s1*5,7)*9), 1-dimensionally equidistributed. Suitable only for mild parallelism (2^32 streams x 2^64 substreams).
RandomDataStreams.Xoroshiro128pp — Type
Xoroshiro128pp <: AbstractStreamableRNGxoroshiro128++ (Blackman & Vigna): 128-bit state, period 2^128 - 1, all-purpose scrambler (rotl(s0+s1,17)+s0). Same parallelism limits as the other 128-bit variants.
RandomDataStreams.Xoshiro256p — Type
Xoshiro256p <: AbstractStreamableRNGxoshiro256+ (Blackman & Vigna): 256-bit state, period 2^256 - 1, output s0 + s3. Slightly faster than **/++ when generating only floating-point numbers from the upper bits; avoid for raw 64-bit consumption.
RandomDataStreams.Xoshiro256ss — Type
Xoshiro256ss <: AbstractStreamableRNGxoshiro256** (Blackman & Vigna): 256-bit state, period 2^256 - 1, all-purpose, 3-dimensionally equidistributed (default PRNG of Lua and .NET 6).
RandomDataStreams.Xoshiro256pp — Type
Xoshiro256pp <: AbstractStreamableRNGxoshiro256++ (Blackman & Vigna): 256-bit state, period 2^256 - 1, all-purpose, 3-dimensionally equidistributed (default PRNG of Julia and Rust's SmallRng). The recommended general-purpose variant.
Examples
julia> rng = Xoshiro256pp(fill(UInt64(42), 4));
julia> rand(rng, UInt64)
0x000000002a00002aRandomDataStreams.Xoshiro512p — Type
Xoshiro512p <: AbstractStreamableRNGxoshiro512+ (Blackman & Vigna): 512-bit state, period 2^512 - 1, output s0 + s2. Floating-point oriented; same caveats as Xoshiro256p.
RandomDataStreams.Xoshiro512ss — Type
Xoshiro512ss <: AbstractStreamableRNGxoshiro512** (Blackman & Vigna): 512-bit state, period 2^512 - 1, all-purpose, 7-dimensionally equidistributed.
RandomDataStreams.Xoshiro512pp — Type
Xoshiro512pp <: AbstractStreamableRNGxoshiro512++ (Blackman & Vigna): 512-bit state, period 2^512 - 1, all-purpose. Offers 2^256 substreams of 2^256 values — more than any application needs; prefer Xoshiro256pp unless you have a specific reason.
Stream generators
RandomDataStreams.LinGen — Type
LinGen{N,S} <: AbstractRNGStreamStream generator producing non-overlapping streams of LinRNG{N,S}: each call to next_stream! applies the family's long jump to the stored seed. Use the exported aliases (Xoroshiro128pGen, ..., Xoshiro512ppGen) instead.
RandomDataStreams.Xoroshiro128pGen — Type
Xoroshiro128pGen <: AbstractRNGStreamStream generator minting non-overlapping Xoroshiro128p streams via a long jump (2^96 values) per call. Seeds are 2 UInt64 words.
RandomDataStreams.Xoroshiro128ssGen — Type
Xoroshiro128ssGen <: AbstractRNGStreamStream generator minting non-overlapping Xoroshiro128ss streams via a long jump (2^96 values) per call. Seeds are 2 UInt64 words.
RandomDataStreams.Xoroshiro128ppGen — Type
Xoroshiro128ppGen <: AbstractRNGStreamStream generator minting non-overlapping Xoroshiro128pp streams via a long jump (2^96 values) per call. Seeds are 2 UInt64 words.
RandomDataStreams.Xoshiro256plusGen — Type
Xoshiro256plusGen <: AbstractRNGStreamStream generator minting non-overlapping Xoshiro256p streams via a long jump (2^192 values) per call. Seeds are 4 UInt64 words.
RandomDataStreams.Xoshiro256pGen — Type
Xoshiro256pGen <: AbstractRNGStreamRegular spelling of Xoshiro256plusGen, matching Xoshiro256ssGen, Xoshiro512pGen and the rest. The two names are the same type.
RandomDataStreams.Xoshiro256ssGen — Type
Xoshiro256ssGen <: AbstractRNGStreamStream generator minting non-overlapping Xoshiro256ss streams via a long jump (2^192 values) per call. Seeds are 4 UInt64 words.
RandomDataStreams.Xoshiro256ppGen — Type
Xoshiro256ppGen <: AbstractRNGStreamStream generator minting non-overlapping Xoshiro256pp streams via a long jump (2^192 values) per call. Seeds are 4 UInt64 words.
RandomDataStreams.Xoshiro512pGen — Type
Xoshiro512pGen <: AbstractRNGStreamStream generator minting non-overlapping Xoshiro512p streams via a long jump (2^384 values) per call. Seeds are 8 UInt64 words.
RandomDataStreams.Xoshiro512ssGen — Type
Xoshiro512ssGen <: AbstractRNGStreamStream generator minting non-overlapping Xoshiro512ss streams via a long jump (2^384 values) per call. Seeds are 8 UInt64 words.
RandomDataStreams.Xoshiro512ppGen — Type
Xoshiro512ppGen <: AbstractRNGStreamStream generator minting non-overlapping Xoshiro512pp streams via a long jump (2^384 values) per call. Seeds are 8 UInt64 words.
Counter-based generators
RandomDataStreams.CBGen — Type
CBGen{B,W,N,K}Hands out independent CBRNG streams, each with its own key. Concrete aliases (PhiloxGen, Philox4x64Gen, ...) are what user code normally names.
The generator walks an odometer over the seeds 0, 1, 2, ... and maps each one through the family's key schedule stream_key to obtain the actual key; see that function for why the two are not the same thing.
GPU primitives
RandomDataStreams.philox4x32_10 — Function
philox4x32_10(ctr::NTuple{4,UInt32}, key::NTuple{2,UInt32}) -> NTuple{4,UInt32}Ten-round Philox4x32 bijection, the primitive PhiloxRNG is built on. Exposed directly for GPU kernels: every thread calls this with its own counter and the stream's key to get its block, with no shared state and no synchronization between threads.
RandomDataStreams.philox4x32_counter — Function
philox4x32_counter(hi::UInt64, lo::UInt64) -> NTuple{4,UInt32}Pack a 128-bit Philox4x32 counter out of two 64-bit halves: hi typically addresses a substream – a GPU thread's global index, so distinct threads never collide – and lo the position within it – a per-thread draw index, so one thread can take several draws. This is the same high/low split next_substream! uses on a PhiloxRNG, exposed as a plain function because a kernel has no stream object to call it on.
Built out of UInt64 shifts and truncations rather than a UInt128 intermediate, since not every GPU compiler backend lowers 128-bit integer arithmetic; only bitwise ops on 64-bit words are needed here, and every backend handles those natively.
RandomDataStreams.open01 — Function
open01(u::UInt64) -> Float64
open01(u::UInt32) -> Float32Map a raw generator word to a uniform value in (0, 1): the conversion every floating-point draw of a counter-based generator applies, scalar or array. Exposed so that a kernel producing raw words – the package's CUDA extension, or one of your own built on philox4x32_10 – matches the CPU bit for bit. A UInt64 word gives a Float64 from its top 52 bits, a UInt32 word a Float32 from its top 23, each as an odd multiple of 2^-53 (2^-24). The one floating-point operation is a subtraction whose exact result is representable, so every IEEE 754 device computes the same value.
Normal and exponential variates
RandomDataStreams.norminv — Function
norminv(u) -> zThe standard normal quantile function Φ⁻¹: the z with Φ(z) = u, for u in (0, 1), and -Inf, Inf at 0 and 1. It is the map every generator of the package uses for randn – randn(rng) is norminv(rand(rng, Float64)) – and is exported so that a randomized quasi-Monte Carlo point, or the uniforms of a kernel of one's own, can be mapped the same way.
Wichura's AS 241 (relative error about 1e-16), computed with correctly rounded IEEE 754 operations only, so a GPU gives the same bits as the CPU. Odd about 1/2: norminv(1 - u) == -norminv(u) whenever 1 - u is exact, which it is for every uniform the word generators return.
A Float32 argument is computed in single precision, by AS 241's PPND7 (about 1e-7 relative error), with the same portability: that is what randn32 uses. A Float16 argument goes through the Float32 method. For the Float64 quantile of a narrower uniform, convert it first.
Base.randn — Method
randn(rng::AbstractStreamableRNG) -> Float64A standard normal by inversion: norminv(rand(rng, Float64)), one uniform per variate. Every generator of the package draws its normals this way, rather than by the standard library's Ziggurat, so that antithetic variates, common random numbers and randomized quasi-Monte Carlo carry through from the uniforms to the normals; see "Normal variates and variance reduction" in the manual. The CUDA extension's randn! computes the same values.
Random.randexp — Method
randexp(rng::AbstractStreamableRNG) -> Float64An exponential variate of rate 1 by inversion, -log(1 - rand(rng, Float64)), for the same reasons as randn.
RandomDataStreams.randn32 — Function
randn32(rng) -> Float32
randn32!(rng, A::AbstractArray{Float32}) -> ASingle-precision standard normals by inversion: norminv(rand(rng, Float32)), computed in Float32 throughout. Faster than randn(rng, Float32) on a GPU whose Float64 rate is low – the CUDA extension's randn32! gives the same values on a CuArray – but its tails end at ±5.29, where randn(rng, Float32), the Float64 normal rounded, reaches ±8.21. One rand(rng, Float32) per normal: one 32-bit word for the counter-based generators, one step for the others.
RandomDataStreams.randn32! — Function
randn32!(rng, A::AbstractArray{Float32}) -> AFill A with randn32 draws, in order: norminv of the Float32 uniforms rand!(rng, A) would give. On a CuArray, the CUDA extension gives the same values.
The GPU fills below take their methods from the CUDA extension, loaded with CUDA.jl. randn! and randexp! on a CuArray need no name of their own: they are the standard ones, and give the CPU's values.
RandomDataStreams.randn_boxmuller! — Function
randn_boxmuller!(rng, A) -> AStandard-normal fill via Box-Muller on the GPU, two uniforms of one Philox4x32 block to two normals. Faster than randn! and branch-free, but it does not carry antithetic variates or randomized quasi-Monte Carlo through, and it matches no CPU output. Only defined for PhiloxRNG/CuArray, by the CUDA extension – see its docstring.
RandomDataStreams.randn_polar! — Function
randn_polar!(rng, A) -> AStandard-normal fill via Marsaglia's polar method (accept-reject), kept only for comparison against inversion (randn!) and randn_boxmuller!. Only defined for PhiloxRNG/CuArray{Float64}, by the CUDA extension – see its docstring.
RandomDataStreams.randn_inversion! — Function
randn_inversion!(rng, A) -> ADeprecated: randn! draws by inversion now, on the CPU and on the GPU, with the same values on both. Forwards to it, on a CuArray, when the CUDA extension is loaded.
Functions
Base.rand — Method
Produces a raw random number with 63 bits of precision, of which a Float64 keeps 53, in (0, 1). The combination k lies in 1:m1 and is scaled by 1/(m1 + 1), but for the twelve largest values of k the product rounds to exactly 1.0 – in the reference C code as well – so the result is capped at prevfloat(1.0). Every other draw is the reference value.
RandomDataStreams.short_jump! — Function
Jumps forward by 2^96 values (xoroshiro128), 2^128 (xoshiro256) or 2^256 (xoshiro512): the start of the next non-overlapping substream.
Jumps forward by 2^64 + 1 values: the start of the next non-overlapping substream. The distance is odd on purpose; see the implementation notes.
RandomDataStreams.long_jump! — Function
Jumps forward by 2^96 (xoroshiro128), 2^192 (xoshiro256) or 2^384 (xoshiro512) values: the start of the next independent stream.
Jumps forward by 2^32 * (2^64 + 1) + 1 values: the start of the next independent stream. The distance is odd on purpose; see the implementation notes.
RandomDataStreams.advance_state! — Function
Given a random number generator, jumps n steps forward if n > 0 (or -n steps backwards if n < 0), where
if e > 0, let n = 2^e + c; if e < 0, let n = -2^(-e) + c; if e = 0, let n = c.
Examples
julia> rng = MRG32k3a();
julia> advance_state!(rng, Int64(2), Int64(-1)); # skip n = 2^2 - 1 = 3 values
julia> rand(rng)
0.8258468629271136Given a random number generator, jumps n steps forward if n > 0 (or -n steps backwards if n < 0), where
if e > 0, let n = 2^e + c; if e < 0, let n = -2^(-e) + c; if e = 0, let n = c.
Examples
julia> rng = MRG63k3a();
julia> advance_state!(rng, Int64(2), Int64(-1)); # skip n = 2^2 - 1 = 3 values
julia> rand(rng)
0.8707612110911583Given a random number generator, jumps n steps forward if n > 0 (or -n steps backwards if n < 0), where
if e > 0, let n = 2^e + c; if e < 0, let n = -2^(-e) + c; if e = 0, let n = c.
The distance is reduced modulo the period (2^(64N) - 1), so any magnitude is accepted. Only the current position moves; the stream/substream boundaries (Bg, Ig) are left untouched. Costs O((64N)^2) GF(2) operations.
Given a random number generator, jumps n steps forward if n > 0 (or -n steps backwards if n < 0), where
if e > 0, let n = 2^e + c; if e < 0, let n = -2^(-e) + c; if e = 0, let n = c.
The distance is reduced modulo the period 2^128, so any magnitude is accepted and a backward jump costs the same as a forward one. Only the current position moves; the stream and substream boundaries are left untouched.
Given a random number generator, jumps n words forward if n > 0 (or -n words backwards if n < 0), where
if e > 0, let n = 2^e + c; if e < 0, let n = -2^(-e) + c; if e = 0, let n = c.
The unit is one rand(rng) draw, the same as for every other generator of the package. A draw takes 64 bits, so it consumes two words of a 32-bit family and one word of a 64-bit one. The distance is reduced modulo the counter space, so any magnitude is accepted. The stream and substream boundaries are not affected, only the current position.
RandomDataStreams.srand! — Function
srand!(gen::MRG32k3aGen, seed) -> genResets the seed that the next next_stream! call will use.
srand!(rng::MRG32k3a, seed) -> rngReseeds the generator, resetting the stream and substream boundaries to seed.
srand!(gen::MRG63k3aGen, seed) -> genResets the seed that the next next_stream! call will use.
srand!(rng::MRG63k3a, seed) -> rngReseeds the generator, resetting the stream and substream boundaries to seed.
Seeds a generator with the first words of seed.
srand!(gen, seed::Vector{UInt64}) -> genResets the seed that the next next_stream! call will use.
Seeds a generator, resetting the stream and substream boundaries to the seed.
srand!(gen::PCGGen, seed) -> genResets the seed that the next next_stream! call will use.
srand!(rng::CBRNG, key) -> rngReseeds the stream with key (a tuple or a vector of key words) and rewinds its counter to the start of the stream.
srand!(gen::CBGen, seed) -> genResets the seed that the next next_stream! call will use.
RandomDataStreams.get_state — Function
get_state return the seed used to generate non-overlaping MRGs
get_state(rng::MRG32k3a) -> Vector{Int}Copy of the current state (Cg); restore it with set_state!.
get_state(gen::MRG63k3aGen) -> Vector{Int}The seed the next next_stream! will use; restore it with set_state!.
get_state(rng::MRG63k3a) -> Vector{Int}The current position, in the same representation as a seed; restore it with set_state!. The internal vector runs one step ahead of it, so this steps back by one – a matrix-vector product, off any hot path.
get_state(rng::LinRNG) -> Vector{UInt64}Copy of the current state (Cg); restore it into a fresh generator via its three-argument constructor.
get_state(gen) -> Vector{UInt64}Seed that will be used by the next next_stream! call.
get_state(rng::PCGRNG) -> UInt128Current state. Hand it back to set_state! to return here.
get_state(gen::PCGGen) -> UInt128Seed that will be used by the next next_stream! call.
get_state(rng::CBRNG) -> (ctr, key, buffer, idx)Full internal state: the index of the next block to produce, the key, the block most recently produced and the position of the next word to consume in it.
get_state(gen::CBGen) -> NTuple{K,W}Seed that the next next_stream! call will use. This is the position in the key schedule, not the key itself; the two coincide only when stream_key is the identity.
RandomDataStreams.set_state! — Function
set_state!(gen::MRG32k3aGen, seed) -> genRestores the seed of the next stream, as returned by get_state(gen).
set_state!(rng::MRG32k3a, state) -> rngRestores the current position from a get_state(rng) value. Only the current state moves; the stream and substream boundaries (Bg, Ig) are untouched.
set_state!(gen::MRG63k3aGen, seed) -> genRestores the seed of the next stream, as returned by get_state(gen).
set_state!(rng::MRG63k3a, state) -> rngRestores the current position from a get_state(rng) value. Only the current state moves; the stream and substream boundaries (Bg, Ig) are untouched.
set_state!(rng::LinRNG, state) -> rngRestores the current position from a get_state(rng) value. Only the current position moves; the stream and substream boundaries (Bg, Ig) are untouched.
set_state!(gen::LinGen, seed) -> genRestores the seed of the next stream, as returned by get_state(gen).
set_state!(rng::PCGRNG, state) -> rngRestores the current position from a get_state(rng) value. Only the current position moves; the stream and substream boundaries are untouched.
set_state!(gen::PCGGen, seed) -> genRestores the seed of the next stream, as returned by get_state(gen).
set_state!(rng::CBRNG, state) -> rngRestores the current position of the stream from a get_state(rng) value: the counter, the key, the buffered block and the index within it.
set_state!(gen::CBGen, seed) -> genRestores the seed of the next stream, as returned by get_state(gen).
RandomDataStreams.next_stream! — Function
next_stream!(gen, n::Integer) -> VectorReturn n successive non-overlapping streams from gen, in order.
This is the thread-safe way to obtain streams for parallel work. A generator object holds the seed of the next stream and rewrites it on every call, so calling next_stream!(gen) from several threads at once is a data race: the threads read the same seed and hand out streams that overlap. The failure is silent — the result is not an error but a set of correlated streams, which is exactly the guarantee the package exists to provide.
Call this once, from one thread, and give each replication its own element:
using Base.Threads
gen = MRG32k3aGen()
rngs = next_stream!(gen, nrep) # serial, here
@threads for r in 1:nrep
rng = rngs[r] # replication r owns stream r
...
endStreams themselves carry no shared state, so drawing from different streams on different threads needs no synchronisation. Indexing them by replication rather than by thread makes the results independent of the number of threads.
Given an RNG generator object, returns the next RNG stream.
Given an RNG generator object, returns the next RNG stream.
Given an RNG generator object, returns the next RNG stream.
Given an RNG generator object, returns the next RNG stream.
next_stream!(gen) -> rngReturns the next independent stream and moves the generator on to the following seed. Seeds are walked in lexicographic order and mapped through stream_key, a bijection, so distinct streams never share a key and their counter spaces cannot overlap.
RandomDataStreams.reset_stream! — Function
Resets a given random number generator to the beginning of the current stream.
Resets a given random number generator to the beginning of the current stream.
reset_stream!(rng) -> rngRewind the generator to the very beginning of its current stream (Cg = Bg = Ig).
reset_stream!(rng) -> rngRewind the generator to the very beginning of its current stream.
reset_stream!(rng) -> rngRewind the generator to the very beginning of its current stream (counter 0).
RandomDataStreams.reset_substream! — Function
Resets a given random number generator to the beginning of the current substream.
Resets a given random number generator to the beginning of the current substream.
reset_substream!(rng) -> rngRewind the generator to the beginning of its current substream (Cg = Bg).
reset_substream!(rng) -> rngRewind the generator to the beginning of its current substream.
reset_substream!(rng) -> rngRewind the generator to the beginning of its current substream.
RandomDataStreams.next_substream! — Function
Takes a random number generator and shifts seed to next substream.
Takes a random number generator and shifts seed to next substream, 2^150 numbers ahead.
next_substream!(rng) -> rngMove the generator to the start of the next substream (anchored jump from Bg): 2^64 values for xoroshiro128, 2^128 for xoshiro256, 2^256 for xoshiro512.
next_substream!(rng) -> rngMove the generator to the start of the next substream: an anchored jump of 2^64 + 1 values from the current substream boundary.
next_substream!(rng) -> rngMove the generator to the start of the next substream: a jump of 2^(_substream_shift) blocks in the counter (2^64 blocks for Philox4x32-10).