<div dir="ltr"><div dir="ltr">On Thu, Dec 17, 2020 at 9:56 AM Evgeni Burovski <<a href="mailto:evgeny.burovskiy@gmail.com">evgeny.burovskiy@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, Dec 17, 2020 at 1:01 PM Matti Picus <<a href="mailto:matti.picus@gmail.com" target="_blank">matti.picus@gmail.com</a>> wrote:<br>
><br>
><br>
> On 12/17/20 11:47 AM, Evgeni Burovski wrote:<br>
> > Just as a side note, this is not very prominent in the docs, and I'm<br>
> > ready to volunteer to send a doc PR --- I'm only not sure which part<br>
> > of the docs, and would appreciate a pointer.<br>
><br>
> Maybe here<br>
><br>
> <a href="https://numpy.org/devdocs/reference/random/bit_generators/index.html#seeding-and-entropy" rel="noreferrer" target="_blank">https://numpy.org/devdocs/reference/random/bit_generators/index.html#seeding-and-entropy</a><br>
><br>
> which is here in the sources<br>
><br>
> <a href="https://github.com/numpy/numpy/blob/master/doc/source/reference/random/bit_generators/index.rst#seeding-and-entropy" rel="noreferrer" target="_blank">https://github.com/numpy/numpy/blob/master/doc/source/reference/random/bit_generators/index.rst#seeding-and-entropy</a><br>
><br>
><br>
> And/or in the SeedSequence docstring documentation<br>
><br>
> <a href="https://numpy.org/devdocs/reference/random/bit_generators/generated/numpy.random.SeedSequence.html#numpy.random.SeedSequence" rel="noreferrer" target="_blank">https://numpy.org/devdocs/reference/random/bit_generators/generated/numpy.random.SeedSequence.html#numpy.random.SeedSequence</a><br>
><br>
> which is here in the sources<br>
><br>
> <a href="https://github.com/numpy/numpy/blob/master/numpy/random/bit_generator.pyx#L255" rel="noreferrer" target="_blank">https://github.com/numpy/numpy/blob/master/numpy/random/bit_generator.pyx#L255</a><br>
<br>
<br>
Here's the PR, <a href="https://github.com/numpy/numpy/pull/18014" rel="noreferrer" target="_blank">https://github.com/numpy/numpy/pull/18014</a><br>
<br>
Two minor comments, both OT for the PR:<br>
<br>
1. The recommendation to seed the generators from the OS --- I've been<br>
bitten by exactly this once. That was a rather exotic combination of a<br>
vendor RNG and a batch queueing system, and some of my runs did end up<br>
with identical random streams. Given that the recommendation is what<br>
it is, it probably means that experience is a singular point and it no<br>
longer happens with modern generators.<br></blockquote><div><br></div><div>I suspect the vendor RNG was rolling its own entropy using time. We use `secrets.getrandbits()`, which ultimately uses the best cryptographic entropy source available. And if there is no cryptographic entropy source available, I think we fail hard instead of falling back to less reliable things like time. I'm not entirely sure that's a feature, but it is safe!</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
2. Robert's comment that `SeedSequence(..., spawn_key=(num,))`  is not<br>
equivalent to `SeedSequence(...).spawn(num)[num]` and that the former<br>
is not recommended. I'm not questioning the recommendation, but then<br>
__repr__ seems to suggest the equivalence:<br></blockquote><div><br></div><div>I was saying that they were equivalent. That's precisely why it's not recommended: it's too easy to do both and get identical streams inadvertently.</div><div> </div></div>-- <br><div dir="ltr" class="gmail_signature">Robert Kern</div></div>