[Scipy-tickets] [SciPy] #1530: Bugs in fit when moments are inf (cauchy, t(1)), scipy 0.9.0 (was: Cauchy fit returns nothing in scipy 0.9.0)

SciPy Trac scipy-tickets@scipy....
Sat Oct 8 09:51:29 CDT 2011


#1530: Bugs in fit when moments are inf (cauchy, t(1)), scipy 0.9.0
------------------------------+---------------------------------------------
 Reporter:  gtg944q           |       Owner:  somebody   
     Type:  defect            |      Status:  new        
 Priority:  normal            |   Milestone:  Unscheduled
Component:  scipy.stats       |     Version:  0.9.0      
 Keywords:  cauchy fit stats  |  
------------------------------+---------------------------------------------

Old description:

> Hello.  I am attempting to fit the cauchy distribution to data in scipy,
> but am receiving errors.  I have verified that my code works in an older
> version of python and scipy (also on a different platform- sorry, this is
> the only other option I have available).  I'll copy and paste below my
> sessions with the python terminal.  Please let me know if you need any
> additional information.  Thanks!
>
> New version, not functioning:
> Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]
> on win
> 32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import scipy
> >>> print scipy.version.version
> 0.9.0
> >>> import scipy.stats as stats
> >>> print stats.cauchy.fit(stats.cauchy.rvs(size=200))
> C:\Python27\lib\site-packages\scipy\stats\distributions.py:1737:
> RuntimeWarning:
>  invalid value encountered in double_scalars
>   Lhat = muhat - Shat*mu
> (nan, 0.0)
> >>> print stats.cauchy.fit(stats.norm.rvs(size=200))
> (nan, 0.0)
> >>> print stats.cauchy.fit(stats.cauchy.rvs(size=200))
> (nan, 0.0)
> >>> print stats.cauchy.fit(stats.cauchy.rvs(size=200))
> (nan, 0.0)
> >>>
>
> Older version, works:
> Python 2.4.5 (#4, Apr 12 2008, 09:09:16)
> [GCC 3.4.1] on sunos5
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import scipy
> >>> print scipy.version.version
> 0.4.7.1617
> >>> import scipy.stats as stats
> >>> print stats.cauchy.fit(stats.cauchy.rvs(size=200))
> [ 0.04395272  0.89676901]
> >>> print stats.cauchy.fit(stats.norm.rvs(size=200))
> [ 0.02706823  0.59303574]

New description:

 Hello.  I am attempting to fit the cauchy distribution to data in scipy,
 but am receiving errors.  I have verified that my code works in an older
 version of python and scipy (also on a different platform- sorry, this is
 the only other option I have available).  I'll copy and paste below my
 sessions with the python terminal.  Please let me know if you need any
 additional information.  Thanks!

 New version, not functioning:

 {{{
 Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]
 on win
 32
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import scipy
 >>> print scipy.version.version
 0.9.0
 >>> import scipy.stats as stats
 >>> print stats.cauchy.fit(stats.cauchy.rvs(size=200))
 C:\Python27\lib\site-packages\scipy\stats\distributions.py:1737:
 RuntimeWarning:
  invalid value encountered in double_scalars
   Lhat = muhat - Shat*mu
 (nan, 0.0)
 >>> print stats.cauchy.fit(stats.norm.rvs(size=200))
 (nan, 0.0)
 >>> print stats.cauchy.fit(stats.cauchy.rvs(size=200))
 (nan, 0.0)
 >>> print stats.cauchy.fit(stats.cauchy.rvs(size=200))
 (nan, 0.0)
 >>>
 }}}

 Older version, works:

 {{{
 Python 2.4.5 (#4, Apr 12 2008, 09:09:16)
 [GCC 3.4.1] on sunos5
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import scipy
 >>> print scipy.version.version
 0.4.7.1617
 >>> import scipy.stats as stats
 >>> print stats.cauchy.fit(stats.cauchy.rvs(size=200))
 [ 0.04395272  0.89676901]
 >>> print stats.cauchy.fit(stats.norm.rvs(size=200))
 [ 0.02706823  0.59303574]
 }}}

--

Comment(by josefpktd):

 change summary line, reformat description

 aside: I wasn't aware of the problem with heavy-tailed distributions in
 statsmodels either, but I didn't use fit_loc_scale, so the problem didn't
 show up in the same way.

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1530#comment:6>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list