bilby.core.utils.random.resolve_random_state

bilby.core.utils.random.resolve_random_state(random_state)[source]

Resolve the provided random state into a random number generator.

Parameters:
random_state: None, int, np.random.Generator, or jax.random.KeyArray

The random state to resolve. If None, the default random generator will be used. If an int, a new numpy.random.default_rng object will be created with that seed. If a numpy.random.Generator, it will be returned as is. If a jax.random.KeyArray, a corresponding orng.RandomGenerator generator will be created and returned.

Returns:
np.random.Generator or orng.RandomGenerator

The resolved random number generator.