[SciPy-Dev] Subversion scipy.stats irregular problem with source code example
josef.pktd@gmai...
josef.pktd@gmai...
Thu Dec 9 15:20:39 CST 2010
On Thu, Dec 9, 2010 at 3:59 PM, Skipper Seabold <jsseabold@gmail.com> wrote:
> On Thu, Dec 9, 2010 at 3:53 PM, <josef.pktd@gmail.com> wrote:
>> On Thu, Dec 9, 2010 at 3:12 PM, Skipper Seabold <jsseabold@gmail.com> wrote:
>>> On Thu, Dec 9, 2010 at 2:34 PM, Charles <charles.moliere@gmail.com> wrote:
>>>>
>>>> Hi,
>>>> I'm very sorry for entering the thread like this, but after a long search over
>>>> the web, this thread is the more relevant to my problem which I'm stuck with.
>>>> I'm actually trying to fit a gamma distribution on a set of experimental
>>>> values with gamma.fit() in scipy 0.8.0. Here is the very simple code I'm using
>>>> with a sample of my data:
>>>>
>>>> ##########################
>>>> import scipy as sp
>>>> import scipy.stats as ss
>>>>
>>>> exp_data =[25.6,35.8,100.2,115.2,125.2,140.1,160.6,210.1,250.5,4500.3]
>>>> data = sp.array(exp_data)
>>>>
>>>> fit_alpha, fit_loc, fit_beta = ss.gamma.fit(data)
>>>> print(fit_alpha,fit_loc,fit_beta)
>>>> #########################
>>>>
>>>> I then receive many messages on the command line:
>>>> Warning: invalid value encountered in subtract
>>>>
>>>> Which ends with no fitting of the parameters:
>>>> (1.0, 0.0, 1.0)
>>>>
>>>> With earlier version of scipy (0.7.2), the error message are absent but still
>>>> no fitting is done. Apparently, it is the extrem value of "4500.3" that is
>>>> causing problem with the fitting in this case.
>>>>
>>>> I know you metionned earlier that the fitting code should be considered as
>>>> experimental, however I was wondering if this should be considered as a bug,
>>>> or if I'm making a mistake. In either case, is there a fix for the fit
>>>> method to work with a gamma distribution?
>>>>
>>>
>>> It looks like Josef's recent changes have got this working. Using the
>>> most recent trunk, so you might want to upgrade or see the changeset
>>
>> I don't remember any changes, but in this case choosing the right
>> starting values will be important, and the default ones might work
>> with one scipy version but with an other.
>>
>
> Ah, well I had an older trunk installed on this machine and got the
> same as the OP. I updated and then it worked (ie., returned
> something)...
with the version I have:
>>> stats.gamma._fitstart([25.6,35.8,100.2,115.2,125.2,140.1,160.6,210.1,250.5,4500.3])
(0.56777181998920023, -422.95393359547484, 1742.449869411083)
>>> stats.gamma.fit([25.6,35.8,100.2,115.2,125.2,140.1,160.6,210.1,250.5,4500.3])
(0.37079853616614639, 25.599999999999998, 2459.7325273317128)
Charles,
you could try starting parameters like (0.5, 0.0, 2000) and see if this works.
I still haven't looked at all the changes in the fit
Josef
>
> Skipper
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
>
More information about the SciPy-Dev
mailing list