Class loguniform_int() - doubt

Dear all,

First of all thanks for this great course. I have been learning soooo much!!! It has been really clear and the explanations so good that even for me that i am a slow learner, it has worked so far.

But today i found this class loguniform_int() and i have some question:

Could you please explain me what is the class doing?

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)

mainly the rvs part is the one i dont understand so much as the other is just apply the log uniform distribution but the rvs is doing something else for sure, i just dont understand what.

Thanks a lot in advance.

Best regards,
Luis.

In scipy.stats most of distribution have rvs method, which produces random variates, i.e. values of a pseudorandom variable sampled from that given distribution. The astype(int) is only truncating the sample to the closest lower integer.

If the use of rvs is still not clear enough, you can take a look at the scipy.stats.loguniform documentation.

1 Like