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 generator (or delayed generator) draws come from, or nil for the process generator.
The generator (or delayed generator) draws come from, or nil for the process generator.
(volatile! [id n]): the identity of the current keyed stream and the
number of decisions drawn from it so far, or nil on the process generator.
`(volatile! [id n])`: the identity of the current keyed stream and the number of decisions drawn from it so far, or nil on the process generator.
(accept-log? log-ratio)The Metropolis–Hastings accept test for a log ratio below zero, drawn as
(< (log u) log-ratio): true with probability exp(log-ratio).
The Metropolis–Hastings accept test for a log ratio below zero, drawn as `(< (log u) log-ratio)`: true with probability exp(log-ratio).
(below? p)True with probability p, drawn as (< u p).
True with probability `p`, drawn as `(< u p)`.
(current)The generator draws come from now.
The generator draws come from now.
(decide probs default)The index of the outcome drawn with probabilities (probs) (normalized),
computed by default from the current generator, or by the installed
oracle. probs is a thunk: a run never builds it.
The index of the outcome drawn with probabilities `(probs)` (normalized), computed by `default` from the current generator, or by the installed oracle. `probs` is a thunk: a run never builds it.
(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-oracle oracle-fn f)Call f with every decision answered by (oracle key probs). For
enumeration in tests: one oracle at a time, process-wide.
Call `f` with every decision answered by `(oracle key probs)`. For enumeration in tests: one oracle at a time, process-wide.
(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. The keyed
generator is seeded only when a draw actually needs it.
Call `f` with draws coming from the stream keyed by `seed` and `key`. A nil seed (no session) leaves draws on the process generator. The keyed generator is seeded only when a draw actually needs it.
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 |