get_random_state

gammapy.utils.random.get_random_state(init)[source]

Get a numpy.random.RandomState instance.

The purpose of this utility function is to have a flexible way to initialise a RandomState instance, a.k.a. a random number generator (rng).

See Random numbers for usage examples and further information.

Parameters:
init : {int, ‘random-seed’, ‘global-rng’, RandomState}

Available options to initialise the RandomState object:

  • int – new RandomState instance seeded with this integer (calls RandomState with seed=init)
  • 'random-seed' – new RandomState instance seeded in a random way (calls RandomState with seed=None)
  • 'global-rng', return the RandomState singleton used by numpy.random.
  • RandomState – do nothing, return the input.
Returns:
random_state : RandomState

RandomState instance.