[Numpy-discussion] NEP: Random Number Generator Policy

Robert Kern robert.kern at gmail.com
Mon Jun 11 03:29:33 EDT 2018


On Sun, Jun 10, 2018 at 11:44 PM Ralf Gommers <ralf.gommers at gmail.com>
wrote:

> Note that scipy.stats distributions allow passing in either a RandomState
instance or an integer as seed (which will be used for seeding a new
instance, not for np.random.seed) [1]. That seems like a fine design
pattern as well, and passing on a seed that way is fairly easy and as good
for reproducibility as passing in a single PRNG.
>
> [1]
https://github.com/scipy/scipy/blob/master/scipy/stats/_distn_infrastructure.py#L612

Well, carefully. You wouldn't want to pass on the same integer seed to
multiple functions. Accepting an integer seed is super-convenient at the
command line/notebooks, though, or docstrings or in tests or other
situations where your "reproducibility horizon" is small. These utilities
are good for scaling from these small use cases to up to large ones.

scikit-learn is also a good example of good PRNG hygiene:


https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/validation.py#L715

>> > Also, if there is to be a multi-year transitioning to the new API,
would there be two PRNG systems anyway during those years?
>>
>> Sure, but with a deadline and not-just-documentation to motivate
transitioning.
>>
>> But if we follow my alternative proposal, there'll be no need for
deprecation! You've convinced me to not deprecate RandomState.
>
> That's not how I had read it, but great to hear that!

Indeed, I did deprecate the name RandomState in that drafting, but it's not
really necessary, and you've convinced me that we shouldn't do it.

--
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180611/e944b2e5/attachment-0001.html>


More information about the NumPy-Discussion mailing list