Skip to content

DOC: clarification about what SeedSequence can and cannot do #25778

Closed

Description

@albertcthomas

Issue with current documentation:

I want to be sure that what SeedSequence can and cannot do is clear from the doc. What I get from the doc is:

  1. SeedSequence can create a good initial state even though I use 0 as my initial seed. This means that even if I use 0 as my seed I will not get any degenerate behavior from my RNG and the subsequent generated numbers will appear random and independent. Is this what is meant by SeedSequence can "ensure that low-quality seeds are turned into high quality initial states (at least, with very high probability)."?
  2. The issue with using small seeds is that this is not covering the initial state space (even with SeedSequence) and therefore we might end up having people running studies with the same initial state which would create biases? So this is mainly to ensure that everyone is unique number?

Idea or request for content:

Maybe clarify what is meant by SeedSequence can "ensure that low-quality seeds are turned into high quality initial states (at least, with very high probability)", as it is also asked to provide large unique numbers for seeds.

Activity

  1. rkern commented on Feb 6, 2024

    @rkern
    Member
    1. Yes, that is the understanding we intended to convey. We go into detail about the problem being avoided in the subsequent paragraph. Without SeedSequence or some other conditioning of the seed (for instance, RandomState was already fine in this respect), 0 or 12345 would have made a bad single instance of MT19937 because of its zero-land properties. Similarly, 0x987...blahmanybitsblah...12345 and 0x987...blahmanybitsblah...12346 would have made a bad single pair of streams for any PRNG except for the weak-crypto ones like Philox.

    2. The remaining issue with small seeds is twofold. First, people don't pull them randomly, even from the set of small integers. Instead, they use convenience seeds like 0, 10, 42, 12345, 31415926. These get repeated a lot.

    Second, even if they did pull randomly from the set of small 32-bit integers and everyone got a unique 32-bit number, the space of 32-bit integers is small relative to the state spaces of modern PRNGs. Even without exact duplicates, there are biases with any particular 4294967296-sized subset of that state space. With SeedSequence and our recommended practice of secrets.randbits(128), we still have a default bottleneck of 128 bits, which is still smaller than our state spaces, but 128 bits is big enough that I don't care much about the remaining bias (and 128 bits is about the most I think I can get away with forcing people to copy-paste).

    Item 2 is entirely orthogonal to Item 1. Our recommendation for big seeds is up in the Quick Start, where I don't really want to overwhelm people with too many details. We discuss Item 1 in the design section about SeedSequence where we can afford to go into details, but because the two issues are fairly orthogonal, I would not have thought to do so there. But I can see reading that discussion and coming away with the impression that SeedSequence dealt with all of the issues with small seeds. A small following note to say that we still recommend secrets.randbits(128) seeds for community practice reasons would probably be reasonable.

  2. albertcthomas commented on Feb 7, 2024

    @albertcthomas
    ContributorAuthor

    Thanks a lot @rkern for the explanation this is very clear! Yes I guess that for most users there is no need to get into that much details. I had overlooked the biases one would get with seeds smaller than the state space and hence the additional reason for having large seeds.

  3. added 3 commits that reference this issue on Apr 24, 2024
    2770f46
    20c707a
    d337663
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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