-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could GLOBAL_RNG
be set like an environment variable?
#23199
Comments
This would essentially prevent precompiling anything that depends on |
But I agree that we really should have some solution to this and that ideally, the global RNG type should be set explicitly any time a seed is provided. |
Sounds great. I can see the technical issue, but it would be a nice feature to have on the user side. |
The environment variable approach is interesting since it's able to affect things before any Julia code actually runs. That could potentially be helpful, but this is still a tricky issue. |
You can set it with If we make |
There is also the problem of unittest. The document says
So if we cannot change global GLOBAL_RNG, we cannot easily switch to another random number generator without change |
Is this now possible? Seems like there'd be multiple hooks that could accomplish this now. |
Possibly more important is that with 1.7, I don't believe you need to do this at all. Since we moved to a faster task local rng, I don't think that doing this would provide the benefit it used to |
The direction we've gone here is that if you care about a specific PRNG sequence then you should not use the global default RNG at all, but should instead use an explicitly constructed and passed around RNG object. In particular, if you want the sequence to never change then you should use StableRNGs.jl, which promise never to change and prioritize stability over performance. |
I'd like to change the default RNG on my system to one of the more efficient implementations from RandomNumbers.jl, so that
rand()
without explicitly passing an RNG works out of the box with the alternative RNG. This would be particularly useful for running library code (which would normally just userand()
without specifying the RNG) on a faster RNG.I understand from https://github.com/sunoru/RandomNumbers.jl/issues/30 that setting GLOBAL_RNG directly is currently not possible unless a Base.Random function is defined that sets it.
See also #18488 which discusses the use of GLOBAL_RNG.
The text was updated successfully, but these errors were encountered: