You are viewing an older version (2.4.3). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / random / RandomState / set_state

cython_function_or_method

numpy.random:RandomState.set_state

Signature

def   set_state ( state )

Summary

Set the internal state of the generator from a tuple.

Extended Summary

For use if one has reason to manually (re-)set the internal state of the bit generator used by the RandomState instance. By default, RandomState uses the "Mersenne Twister"[1] pseudo-random number generating algorithm.

Parameters

state : {tuple(str, ndarray of 624 uints, int, int, float), dict}

The state tuple has the following items:

  • the string 'MT19937', specifying the Mersenne Twister algorithm.

  • a 1-D array of 624 unsigned integers keys.

  • an integer pos.

  • an integer has_gauss.

  • a float cached_gaussian.

If state is a dictionary, it is directly set using the BitGenerators state property.

Returns

out : None

Returns 'None' on success.

Notes

set_state and get_state are not needed to work with any of the random distributions in NumPy. If the internal state is manually altered, the user should know exactly what he/she is doing.

For backwards compatibility, the form (str, array of 624 uints, int) is also accepted although it is missing some information about the cached Gaussian value: state = ('MT19937', keys, pos).

See also

get_state

Aliases

  • numpy.random.set_state
  • numpy.random.RandomState.set_state