Is there are more direct way to access the RandomState object created on import other than np.random.<some function>.__self__? Both np.random._rand and getattr(np.random, "_rand") raise AttributeError. The former works fine but doesn't seem very transparent/Pythonic, though the most transparent might just be creating a separate RandomState object. The purpose is passing the interal_state variable to a cython function that calls randomkit functions directly.
Direct way to access Numpy RandomState object
333 Views Asked by deasmhumnha At
2
You can use
np.random.get_state()to access the random state andnp.random.set_state()to set it.Example usage:
Note that
stateis just a tuple