geossm.utils.KeyStream¶
- class geossm.utils.KeyStream(seed)[source]¶
Bases:
objectStateful helper that hands out fresh JAX PRNG keys on demand.
Wraps a single
jax.random.PRNGKeyand splits it on every call to next, so callers never have to thread/split keys manually or risk reusing the same key twice (e.g. across successive simulation calls ingeossm.ssm.StateSpaceModel.sim()).- Parameters:
seed (
jax.random.PRNGKeyorint) – Initial key (or integer seed, though JAX generally expects an already-constructedPRNGKey) used to derive all subsequent keys.
Methods
Return one or more fresh keys, advancing the internal state.
- next(num=None)[source]¶
Return one or more fresh keys, advancing the internal state.
- Parameters:
num (
int, optional) – If given, return num independent keys (shape(num, ...)) instead of a single one; the internal state is advanced accordingly so the next call continues from a key independent of all of them.- Returns:
jax.random.PRNGKeyorjax.numpy.ndarray– A single new key, or an array of num keys if num was given.