uvex_transients.utils.spawn_seeds#
- uvex_transients.utils.spawn_seeds(spawn_sequence: SeedSequence, n: int, indices: ArrayLike | None = None) NDArray[uint64][source]#
Derive
nindependent, reproducible, individually storable seeds.Each returned seed is a single
uint64, directly usable withget_rng()(e.g. asLightcurve.sample_parameters(rng=seed)) to reproducibly regenerate that one event’s parameters later without needing to replay the draws for any other event – the compression trick behind only ever storing a seed per event rather than its sampled parameters.Uses ~numpy.random.SeedSequence.spawn, which is NumPy’s recommended mechanism for generating many independent reproducible streams from one root; a naive
base_seed + ischeme is not guaranteed to avoid subtle stream correlations the way spawning is.- Parameters:
spawn_sequence (
numpy.random.SeedSequence) – Typically the second element returned bysplit_root_seed().n (
int) – Number of seeds to derive.indices (
array_likeofint, optional) – If given, only the seeds at these positions of the full length-nset are returned, and the rest are never built. Each is identical to the same position of the full set, since childiof a ~numpy.random.SeedSequence is just the sequence withspawn_key + (n_children_spawned + i,); building one directly costs the same as spawning it, so a small subset of a largenis far cheaper. Unlike a full spawn, this does not advancespawn_sequence.n_children_spawned(NumPy does not allow setting it), so only use it on a sequence that is not spawned from again.
- Returns:
uint64array of shape(n,), or(len(indices),)if indices is given.- Return type: