Rvs function

Hi,

I have a little trouble understanding how the rvs function actually works.
We define rvs but in the function rvs is called, as it was a recursive process, and then there is astype().
But how don’t we get an infinite recursive loop ? Because in the function, the function rvs itself is called (and then transformet into an integer). But I m sure Im missing sthg about the objects at stake, the reason why I don’t really understand.

Thank you for your help (and all the previous valuable answers !)

Geoffrey

Let me first copy-paste the class of interest:

from scipy.stats import loguniform


class loguniform_int:
    """Integer valued version of the log-uniform distribution"""
    def __init__(self, a, b):
        self._distribution = loguniform(a, b)

    def rvs(self, *args, **kwargs):
        """Random variable sample"""
        return self._distribution.rvs(*args, **kwargs).astype(int)

Indeed, there is not recursion here. Our method rvs is calling the rvs method of the distribution passed during __init__. In short without the .astype(int), it would be equivalent to just call loguniform.rvs().

We just wrap logunitform.rvs to round it to an integer.

ok thanks !