Skip to content

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

Closed
@maichmueller

Description

@maichmueller

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions