Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRNG convention #121

Open
stefanv opened this issue Jul 26, 2023 · 1 comment
Open

PRNG convention #121

stefanv opened this issue Jul 26, 2023 · 1 comment

Comments

@stefanv
Copy link
Collaborator

stefanv commented Jul 26, 2023

Right now, in some places, rnd = np.random.default_rng() is used.

To me, it feels better to consistently use the pattern rng = np.random.default_rng(). This is the pattern encouraged in the NumPy docs and which is used in the library ecosystem.

@matthew-brett
Copy link
Member

You probably remember - we discussed this a fair bit at the time. The problem that I saw, was that we were too early to introduce the idea of methods. rng reads as "random number generator" and so it's obvious that rng is a value and that rng.choice is a function attached to a value - a method. Whereas rnd.choice allows the student to feel that rnd is a bit like np - just a namespace, and that rnd.choice is just a function in a namespace, like np.sum.

Against that we have the Numpy default convention - but I don't think that's a very strong argument. I don't think they will be all that confused, in due course, by code with rng.choice instead of rnd.choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants