10

Generator sounds like a replacement for RandomState, and the way of the future for generating random numbers in NumPy.

What features or behavior (currently or planned) does Generator have that RandomState doesn't?

Both can be parameterized with BitGenerator objects. They have some different methods, but the vast majority appear to be the same.

Relevant links:

2
  • Any luck / yet!?
    – jtlz2
    Commented Aug 10, 2021 at 9:22
  • 1
    @jtlz2 wish i could say yes Commented Aug 10, 2021 at 21:14

1 Answer 1

2

As of numpy version 1.23, they list 9 differences at What’s New or Different. To better understand the logic behind the change, I'd recommend reading NEP 19

TLDR:

  1. API changes "cleaned up"
  2. Performance changes, mostly due to switching from Box-Muller to Ziggurat algorithms it seems. Some go to 4x faster with the new approach. See Performance
  3. Numba and Cython compatible BitGenerators.
  4. New dtype, out and axis arguments to fill parts of existing arrays and to control output datatypes.
1
  • whoa, numba compatible BitGenerators. I wonder if anything works with jax, too? Commented Sep 6, 2022 at 19:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.