In common understanding, “1 2 3 4 5” is not as random as “3 5 2 1 4” and certainly not as random as “47 88 1 32 41” but “we can’t say authoritatively that the first sequence is not random … it could have been generated by chance.” —Wikipedia

If you do an online search about how to generate random numbers in Python NumPy, most probably you will see this kind of code

Sometime ago NumPy had updated its method of generating random numbers but almost all of the search results are littered with outdated code like above, even today. So I decided to write a small blog-post about explaining the updated method. The outdated method (known as **legacy RandomState **in NumPy documentation) still works but it is 2–10 times slower than the newer method.

So, how do you generate random numbers now?

#data-science #python #numpy #matplotlib #random-number-generator

1.10 GEEK