import numpy as np import os def init_rng(seed=None): ''' Set a random number generator with a random seed :return: a random number generator and the related seed :rtype: tuple(mtrand.RandomState, int) ''' if seed is None: seed = np.fromstring(os.urandom(4), dtype=np.uint32)[0] rng = np.random.RandomState(seed) return rng, seed rng, seed = init_rng() print rng.randn(5)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question