[Scipy-tickets] [SciPy] #1493: scipy.stats.invnorm.ppf fails
SciPy Trac
scipy-tickets@scipy....
Fri Aug 12 20:37:33 CDT 2011
#1493: scipy.stats.invnorm.ppf fails
-------------------------+--------------------------------------------------
Reporter: mw263 | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: scipy.stats | Version: 0.9.0
Keywords: |
-------------------------+--------------------------------------------------
Changes (by josefpktd):
* component: Other => scipy.stats
Comment:
ppf is solved for numerically, xa and xb are the bounds for the solver
(brentq).
In the failing case xb is too small. It can be reset by assignment.
{{{
>>> stats.invnorm.ppf(0.8455, 7.24000019602, scale=2.51913630166)
25.187834528234671
>>> stats.invnorm.xb
10.0
>>> stats.invnorm.xa
-10.0
>>> stats.invnorm.xb = 20
>>> stats.invnorm.ppf(0.8465, 7.24000019602, scale=2.51913630166)
25.390178273818787
}}}
xa, xb are usually set so that it has a "reasonable" range for most
values. Until now I have seen only failures for quantiles close to 1, e.g.
0.999.
I don't know what the shape for invnorm is. If xb is too low, then it
should be increased in scipy.
However, there will always be cases where xa or xb are too large or too
small for brentq to work. for example with xb=20:
{{{
>>> stats.invnorm.ppf(0.99, 7.24000019602, scale=2.51913630166)
Traceback (most recent call last):
<....>
ValueError: f(a) and f(b) must have different signs
}}}
One suggestion: catch this exception from brentq and try again, either
with widened interval (xa,xb) or switch to fsolve which does not require
bounds, but might be slower in general.
--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1493#comment:1>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
More information about the Scipy-tickets
mailing list