Skip to content

Enhancement: Extend seeding option to a numpy RandomState/Generator #4301

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

Closed
maichmueller opened this issue Dec 5, 2020 · 0 comments · Fixed by #5787
Closed

Enhancement: Extend seeding option to a numpy RandomState/Generator #4301

maichmueller opened this issue Dec 5, 2020 · 0 comments · Fixed by #5787

Comments

@maichmueller
Copy link

maichmueller commented Dec 5, 2020

Hello,

I would like to discuss the possibility of adding the option of passing a numpy RandomState or Generator as 'seed', in order to seed via a client maintained rng state machine.

SciPy allows the seed to be used like this:

seed{None, int, RandomState, Generator}, optional
This parameter defines the object to use for drawing random variates. If seed is None the RandomState singleton is used. If seed is an int, a new RandomState instance is used, seeded with seed. If seed is already a RandomState or Generator instance, then that object is used. Default is None.

as is mentioned here.

This would have the following advantages:

  • Thread-safe seeding
  • Non-interference by other code (setting the seed via np.random.seed(seed) is vulnerable to outside manipulation and prone to create hard to detect bugs)
  • Client decided RNG source if needed, but especially client maintained and manipulated if desired.

I am unfamiliar with the pymc3 code base and have only seen the 'seed' parameter used via np.random.seed in the few files I have searched, but it seemed like it could be generally made to support generators.

What are your thoughts on this?

Cheers,
Michael

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants