XqZ
XqZ

Reputation: 1

Something wrong with scipy.stats.lognorm.fit()

Can anyone help me this is literally my first question. I usually tried to find similar question before asking one, but this problem bugs me so much, and I really think something is wrong with the scipy lib.

For example, if you create a sequence of lognormal random variables:

from scipy.stats import lognorm
rvs = lognorm.rvs(size = 1000, s = 0.75, loc = 25, scale = 3)

If you want to fit this distribution, you might want to use:

args = lognorm.fit(rvs, s = 0.75)

But it shows error, saying no keyword for 's'. This is really bugging me, if you read the manual: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.lognorm.html#scipy.stats.lognorm it should be right

Then if you do something like:

args = lognorm.fit(rvs, loc = 25, scale = 3)

it works! and then if you try something like:

param = (25,3)
args = lognorm.fit(rvs, *param)

then another error. Anyone can help me?

Upvotes: 0

Views: 266

Answers (1)

DrBwts
DrBwts

Reputation: 3657

From the lognorm docs,

As an instance of the rv_continuous class, lognorm object inherits from it a collection of generic methods.

I.e. the fit method is inherited from rv_continuous

If look at the docs for rv_continuous you will see that the fit method doesn't have an argument called s. See here for docs for the fit method.

As your exmaple shows, this is plainly the case.

The docs for lognorm are at best misleading. I have reported the issue here

Upvotes: 1

Related Questions