-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
numpy.random.RandomState() fails silently if /dev/urandom returns nothing #14844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you a 8000 gree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Actually, I misread the output from |
Only the first element of the state is deterministic. The rest of the state is initialized correctly from the seeding data provided by @mattip The bug is in this line: https://github.com/numpy/numpy/blob/master/numpy/random/_mt19937.pyx#L132 You're supposed to https://github.com/numpy/numpy/blob/v1.16.3/numpy/random/mtrand/randomkit.c#L186 |
Actually, this is not true. The lower 31 bits of the first word in the state never get used by the algorithm. https://github.com/numpy/numpy/blob/v1.17.3/numpy/random/src/mt19937/mt19937.c#L87-L90
This is why the algorithm has a period of Back when The fact that |
For some reason, I get nothing back when I run
cat /dev/urandom | base64 | head -c 5
on my system. This turns numpy deterministic silently.Reproducing code example:
Running
should print two different numbers. I get the same number twice.
Numpy/Python version information:
1.17.3 3.7.5 (default, Oct 17 2019, 12:09:47)
[GCC 9.2.1 20190827 (Red Hat 9.2.1-1)]
The text was updated successfully, but these errors were encountered: