I was trying to play around with the print/pprint/dir on randint, and read the documentation but I could not understand what values was tested in the search of the solution.
randint
is the following function: scipy.stats.randint — SciPy v1.9.3 Manual
It represents a uniform distribution that generates values integer values between a given minimum and maximum. Since it is a distribution, you get several methods available such as the CDF, PDF, or generating a random sample from it. As an example:
The following code will create a uniform distribution defined between 0 and 10
In [1]: import scipy as sp
In [3]: distribution = sp.stats.randint(low=0, high=10)
In [4]: distribution
Out[4]: <scipy.stats._distn_infrastructure.rv_discrete_frozen at 0x109d2f520>
We see that distribution
itself is only a distribution. Calling it is not generating a sample. However, we can use the rvs
method for that:
In [5]: distribution.rvs?
Signature: distribution.rvs(size=None, random_state=None)
Docstring: <no docstring>
File: ~/mambaforge/envs/dev/lib/python3.10/site-packages/scipy/stats/_distn_infrastructure.py
Type: method
In [6]: distribution.rvs(size=10)
Out[6]: array([5, 3, 4, 9, 3, 1, 9, 4, 5, 4])
The RandomizedSearchCV
understand those methods and will call rvs
under the hood. This is the usual API defined by scipy when it comes to defining these distributions.
1 Like