Skip to content

DOC: remove references to RandomState #11519

Closed

Description

@tupui

Description

I propose here to remove from the documentation any reference to RandomState and wrong (not best practice) usage of random number generators.

We went through this in SciPy. More on the PR scipy/scipy#13778

Let me know if you would accept this contribution and I would propose to do it 😃

Additional context

Since NumPy 1.17 (and as far as I understand, the supported minimal version here is 1.17), the canonical way to create random numbers is:

import numpy as np
from numpy.random import default_rng
rng = default_rng()

And If a seed is to be used. User should not use a common value such as 0 or 123456. This is to prevent bias (everyone is using the same values) and ensure sufficient entropy for the generator. More details. The good practice (from NumPy's doc) is to generate a seed like this:

from numpy.random import SeedSequence
print(SeedSequence().entropy)

Then you can use the value like

rng = default_rng(my_seed_generated_and_not_common_value)

Activity

  1. github-actions commented on Apr 12, 2021

    @github-actions
    Contributor

    Welcome to Astropy 👋 and thank you for your first issue!

    A project member will respond to you as soon as possible; in the meantime, please double-check the guidelines for submitting issues and make sure you've provided the requested details.

    If you feel that this issue has not been responded to in a timely manner, please leave a comment mentioning our software support engineer @embray, or send a message directly to the development mailing list. If the issue is urgent or sensitive in nature (e.g., a security vulnerability) please send an e-mail directly to the private e-mail [email protected].

  2. pllim commented on Apr 12, 2021

    @pllim
    Member

    Hello. We already have #10644 to address this, but unfortunately, it is still awaiting approval and merge (looks like it needs a rebase now too...)

  3. tupui commented on Apr 12, 2021

    @tupui
    Author

    Indeed sorry I don't know how I missed it when searching for it!

  4. reopened this on Apr 12, 2021
  5. pllim commented on Apr 12, 2021

    @pllim
    Member

    No worries. I am re-opening this because it is technically not fixed yet. The PR will auto-close this issue when it is merged. Thanks for pinging us!

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