package nx
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=96d35ce03dfbebd2313657273e24c2e2d20f9e6c7825b8518b69bd1d6ed5870f
sha512=90c5053731d4108f37c19430e45456063e872b04b8a1bbad064c356e1b18e69222de8bfcf4ec14757e71f18164ec6e4630ba770dbcb1291665de5418827d1465
doc/nx.core/Nx_core/Rng/index.html
Module Nx_core.RngSource
RNG key utilities.
Splittable RNG keys and implicit key management.
Keys are deterministic integers that can be split to derive independent subkeys. run and with_key install an effect handler that provides implicit key threading via next_key; outside any handler a domain-local auto-seeded generator is used as a convenient fallback.
Keys
The type for RNG keys.
split ?n k deterministically derives n subkeys from k.
n defaults to 2.
Implicit key management
next_key () returns a fresh subkey from the current RNG scope.
Inside a run or with_key block, each call returns a deterministically derived key. Outside any scope, falls back to a domain-local auto-seeded generator (convenient but non-reproducible).
Two calls to next_key () always return different keys.
run ~seed f executes f in an RNG scope seeded by seed.
Every next_key call within f returns a deterministically derived key. The same seed and the same sequence of next_key calls produce the same keys. Scopes nest: an inner run replaces the outer scope for its duration.