[Scipy-tickets] [SciPy] #1262: scipy.stats.maxwell.ppf(0.25)=0?
SciPy Trac
scipy-tickets@scipy....
Fri Aug 13 12:12:22 CDT 2010
#1262: scipy.stats.maxwell.ppf(0.25)=0?
-----------------------+----------------------------------------------------
Reporter: pozharski | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 0.9.0
Component: Other | Version: 0.7.0
Keywords: |
-----------------------+----------------------------------------------------
The problem is clear from the summary. I get
scipy.stats.maxwell.ppf(0.2499999999999999) = 1.1011507176793141
scipy.stats.maxwell.ppf(0.25) = 0.0
scipy.stats.maxwell.ppf(0.2500000000000001) = 1.1011507176793145
I looked in the distributions.py and scipy.stats.maxwell.ppf is calculated
used scipy.special.gammaincinv, which shows the same behavior of returning
zero when the argument is exactly 0.25.
I found this bug report
[http://projects.scipy.org/scipy/ticket/299]
which says
''This should be fixed in r4171. I use false position to find the root of
gammainc(a,x)-y=0 for y < 0.25.
''
This led me to scipy/special/c_misc/gammaincinv.c which produces the
artifact. With y=0.25 you get fhi=0.0 which results in false_position
returning FSOLVE_NOT_BRACKET and the return value of gammaincinv being set
to 0.0.
I guess the remedy would be to change line 28 to this
{{{
if (a <= 0.0 || y <= 0.0 || y >= 0.25) {
}}}
It is also possible that false_position harbors a bug in line 63. If
f1*f2==0, shouldn't it return the solution (either left or right side of
the interval depending on which of f1 and f2 is zero). It seems that
gammaincinv/maxwell bug wouldn't exist if false_position were to exhibit
such (presumably correct) behavior.
--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1262>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
More information about the Scipy-tickets
mailing list