[SciPy-Dev] Subversion scipy.stats irregular problem with source code example
Skipper Seabold
jsseabold@gmail....
Thu Dec 9 14:59:35 CST 2010
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)...
Skipper
More information about the SciPy-Dev
mailing list