uvex_transients.utils.spawn_seeds#

uvex_transients.utils.spawn_seeds(spawn_sequence: SeedSequence, n: int, indices: ArrayLike | None = None) → NDArray[uint64][source]#

Derive n independent, reproducible, individually storable seeds.

Each returned seed is a single uint64, directly usable with get_rng() (e.g. as Lightcurve.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 + i scheme is not guaranteed to avoid subtle stream correlations the way spawning is.

Parameters:
  • spawn_sequence (numpy.random.SeedSequence) – Typically the second element returned by split_root_seed().

  • n (int) – Number of seeds to derive.

  • indices (array_like of int, optional) – If given, only the seeds at these positions of the full length-n set are returned, and the rest are never built. Each is identical to the same position of the full set, since child i of a ~numpy.random.SeedSequence is just the sequence with spawn_key + (n_children_spawned + i,); building one directly costs the same as spawning it, so a small subset of a large n is far cheaper. Unlike a full spawn, this does not advance spawn_sequence.n_children_spawned (NumPy does not allow setting it), so only use it on a sequence that is not spawned from again.

Returns:

uint64 array of shape (n,), or (len(indices),) if indices is given.

Return type:

numpy.ndarray