[SciPy-dev] Sad sad sad... Was: Warning about remaining issues in stats.distributions ?

Yaroslav Halchenko lists@onerussian....
Mon Mar 16 12:31:22 CDT 2009


Thanks Josef once again.

I have tested s/pow/N.power/ in rdist and it seems to work great! thanks a lot.

numpy is more fun though than I thought ;)

In [12]:np.power(0, -1)
Out[12]:-9223372036854775808

In [14]:np.power(0.0, -1)
Out[14]:inf

In [16]:np.power(0, -1.0)
Out[16]:inf

I know that in my case I will not (or should not) get ints as input but... I
thought it might be worth mentioning... may be it is worth a bug report
in numpy?

On Fri, 13 Mar 2009, josef.pktd@gmail.com wrote:

> > The solution to the rdist problem is trivial:

> >>>> np.power(1-1.,-2)
> > inf
> >>>> pow(1-1.,-2)
> > Traceback (most recent call last):
> >  File "<pyshell#163>", line 1, in <module>
> >    pow(1-1.,-2)
> > ZeroDivisionError: 0.0 cannot be raised to a negative power


> It only partially helped, it doesn't raise an exception anymore, but the inf is
> incorrect

> >>> stats.rdist(1.32, 0, 1).cdf(-1.0+np.finfo(float).eps)
> Warning: Extremely bad integrand behavior occurs at some points of the
>   integration interval.
> Warning: Extremely bad integrand behavior occurs at some points of the
>   integration interval.
> inf
> >>> stats.rdist(1.32, 0, 1).cdf(-1.0+1e-14)
> Warning: Extremely bad integrand behavior occurs at some points of the
>   integration interval.
> inf

> further away from the boundary it looks good
> >>> stats.rdist(1.32, 0, 1).cdf(-1.0+1e-12)
> 5.5125207421811825e-009
> >>> stats.rdist._cdf_skip(-1.0+1e-12, 1.32)
> 5.5260225839681709e-009
> >>> stats.rdist._cdf_skip(-1.0+1e-13, 1.32)
> 1.2092278844910709e-009
> >>> stats.rdist(1.32, 0, 1).cdf(-1.0+1e-13)
> 1.2060822041379395e-009

> so back to fiddling with the boundary ?
> so just do
> >>> stats.rdist.a = -1.0+np.finfo(float).eps
> before calling rdist, this works in some basic tests.

> Josef
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev


-- 
                                  .-.
=------------------------------   /v\  ----------------------------=
Keep in touch                    // \\     (yoh@|www.)onerussian.com
Yaroslav Halchenko              /(   )\               ICQ#: 60653192
                   Linux User    ^^-^^    [175555]




More information about the Scipy-dev mailing list