Scipy randint vs numpy randint

I have a simple but broad question regarding two methods:

scipy.stats.randint 

and

 numpy.random.randint 

After reading the API for both methods, I'm a little confused when it is best to use each method; so I was wondering if someone could spot the differences between them and maybe offer some examples of when one method would be preferable to use each other. Thanks!

Edit: links to each method documentation - > numpy.random.randint , scipy.stats.randint

+5
source share
1 answer

The main difference is that scipy.stats.randint allows scipy.stats.randint to explicitly specify the lower or upper probability of the tail, as well as determine the distributions from which you want to get random ints (see the scipy.stats.randint methods section of the documentation). Therefore, it is much more useful if you want to draw random intervals from a given density function.

If you really want to draw a random integer that falls within a certain range, without any distribution requirements, then numpy.random.randint is simpler. They will be drawn directly from a discrete uniform distribution, with no built-in option to change this.

+1
source

Source: https://habr.com/ru/post/1275631/


All Articles