resampling-stats / resampling-with

Source repository for third edition of "Resampling: The New Statistics"
https://resampling-stats.github.io
Other
11 stars 9 forks source link

PRNG convention #121

Open stefanv opened 1 year ago

stefanv commented 1 year ago

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 commented 1 year ago

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.