[SciPy-user] use of rv_continuous "fit"?

Travis Oliphant oliphant at ee.byu.edu
Mon Aug 29 18:28:39 CDT 2005

lindeman at bard.edu wrote:

>I do realize that the normal distribution is defined by mean and variance, so
>this particular example is rather futile. I was deliberately trying to use a
>trivial example to help me figure out the calling conventions, etc. throughout
>the package.  It's _possible_ that fit() is broken, but more likely that my
>understanding is.

It is actually likely that .fit is broken because it and nnlf was rather 
loosely hacked together as an after thought to the rest of the 
distribution infrastructure which is in much better shape.   I just ran 
some tests and it looks like there may be some problems.

One thing that might help is that all distributions take location and 
scale keyword arguments, in addition, to any parameters they may have.

Thus, you are always going to fit to these parameters as well.  (The 
default initial guesses for these values are 0.0 and 1.0 which you can 
alter by passing keyword arguments in to fit).

So, a Gaussian distribution will have no other arguments and would be 
called as

res = stats.norm.fit(data)

res would be just the location and scale parameters since there are no 
shape parameters.

I just tried this and I get an error because of calling conventions to 
nnlf.  This needs to be fixed.


More information about the SciPy-user mailing list