Numpy documentation on np.random.permutation
suggests all new code use np.random.default_rng()
from the Random Generator package. I see in the documentation that the Random Generator package has standardized the generation of a wide variety of random distributions around the BitGenerator vs using Mersenne Twister, which I'm vaguely familiar with.
I see one downside, what used to be a single line of code to do simple permutations:
np.random.permutation(10)
turns into two lines of code now, which feels a little awkward for such a simple task:
rng = np.random.default_rng()
rng.permutation(10)
- Why is this new approach an improvement over the previous approach?
- And why wouldn't existing methods like
np.random.permutation
just wrap this new preferred method? - Is there a good reason not to use this new method as a one-liner
np.random.default_rng().permutation(10)
, assuming it's not being called at high volumes? - Is there an argument for switching existing code to this method?