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

josef.pktd@gmai... josef.pktd@gmai...
Fri Mar 13 11:44:43 CDT 2009


> 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


More information about the Scipy-dev mailing list