[Numpy-discussion] reseed random generator (1.19)

Neal Becker ndbecker2 at gmail.com
Mon Jun 29 08:00:23 EDT 2020

I was using this to reset the generator, in order to repeat the same
sequence again for testing purposes.

On Wed, Jun 24, 2020 at 6:40 PM Robert Kern <robert.kern at gmail.com> wrote:

> On Wed, Jun 24, 2020 at 3:31 PM Neal Becker <ndbecker2 at gmail.com> wrote:
>> Consider the following:
>> from numpy.random import default_rng
>> rs = default_rng()
>> Now how do I re-seed the generator?
>> I thought perhaps rs.bit_generator.seed(), but there is no such attribute.
> In general, reseeding an existing generator instance is not a good
> practice. What effect are you trying to accomplish? I assume that you are
> asking this because you are currently using `RandomState.seed()`. In what
> circumstances?
> The raw `bit_generator.state` property *can* be assigned to, in order to
> support some advanced use cases (mostly involving de/serialization and
> similar kinds of meta-programming tasks). It's also been helpful for me to
> construct worst-case scenarios for testing parallel streams. But it quite
> deliberately bypasses the notion of deriving the state from a
> human-friendly seed number.
> --
> Robert Kern
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion

*Those who don't understand recursion are doomed to repeat it*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20200629/65c5be1c/attachment.html>

More information about the NumPy-Discussion mailing list