Where inference draws its randomness from.
Every draw of a seeded inference run must depend only on WHAT is drawn, not on when: particles, chains and proposals run concurrently, and one generator shared in arrival order makes a seeded run reproducible only on a serial executor. So a draw made while deciding something in a world — a sample site, the site an MH move selects, its acceptance — reads a STREAM keyed by that world's seed and what is being decided:
stream(world, key) = generator seeded by hash(seed(world), key)
World seeds are derived per fork from the parent's seed, the site address
and the fork index (savepoint/fork), so a replay's fresh proposal draws
from a fresh stream and the same run draws the same numbers. Draws outside
any world — the seeds of an inference's sessions, SMC's resampling at a
barrier — come from the process generator in program order, which
set-seed! seeds.
The generator is xoshiro128** on 32-bit words, so a seed gives the same numbers on the JVM and in JavaScript.
Where inference draws its randomness from. Every draw of a seeded inference run must depend only on WHAT is drawn, not on when: particles, chains and proposals run concurrently, and one generator shared in arrival order makes a seeded run reproducible only on a serial executor. So a draw made while deciding something in a world — a sample site, the site an MH move selects, its acceptance — reads a STREAM keyed by that world's seed and what is being decided: stream(world, key) = generator seeded by hash(seed(world), key) World seeds are derived per fork from the parent's seed, the site address and the fork index (`savepoint/fork`), so a replay's fresh proposal draws from a fresh stream and the same run draws the same numbers. Draws outside any world — the seeds of an inference's sessions, SMC's resampling at a barrier — come from the process generator in program order, which `set-seed!` seeds. The generator is xoshiro128** on 32-bit words, so a seed gives the same numbers on the JVM and in JavaScript.
The stream draws come from, or nil for the process generator.
The stream draws come from, or nil for the process generator.
(current)The generator draws come from now.
The generator draws come from now.
(fresh-seed)A seed for a new session, drawn from the current generator: in a seeded run, the same seeds in the same program order.
A seed for a new session, drawn from the current generator: in a seeded run, the same seeds in the same program order.
(generator seed)A generator seeded by seed (any value).
A generator seeded by `seed` (any value).
(in-world-stream world key f)Call f drawing from world's stream for key.
Call `f` drawing from `world`'s stream for `key`.
(next-double! g)The next double in [0, 1) of g: 53 random bits.
The next double in [0, 1) of `g`: 53 random bits.
(next-u32! g)The next unsigned 32-bit word of g.
The next unsigned 32-bit word of `g`.
(set-seed! seed)Seed the process generator: the draws made outside any world stream.
Seed the process generator: the draws made outside any world stream.
(uniform01)A uniform draw in [0, 1) from the current generator.
A uniform draw in [0, 1) from the current generator.
(with-stream* seed key f)Call f with draws coming from the stream keyed by seed and key. A nil
seed (no session) leaves draws on the process generator.
Call `f` with draws coming from the stream keyed by `seed` and `key`. A nil seed (no session) leaves draws on the process generator.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |