[Scipy-tickets] [SciPy] #1291: stats.discrete distributions hypergeom.sf exception
SciPy Trac
scipy-tickets@scipy....
Fri Oct 22 11:50:21 CDT 2010
#1291: stats.discrete distributions hypergeom.sf exception
-------------------------+--------------------------------------------------
Reporter: josefpktd | Owner: somebody
Type: defect | Status: needs_review
Priority: normal | Milestone: 0.9.0
Component: scipy.stats | Version: 0.7.0
Keywords: |
-------------------------+--------------------------------------------------
Comment(by josefpktd):
Thanks for looking into this.
I don't think the solution is correct (just reading, I haven't tried it
out)
if k is a scalar in the support of the distribution, then output is a
scalar and I don't think you can place into a scalar
{{{
>>> a = np.array(5)[()]
>>> a
5
>>> np.place(a, [True], [6])
>>> a
5
>>> a = np.array([5])[()]; np.place(a, [True], [6])
>>> a
array([6])
}}}
this is a test case that I think should break
{{{
>>> stats.hypergeom.sf(1,10,2,5)
0.22222222222222165
}}}
Can you try the scalar case with your changes?
One possible solution might be to check whether goodargs is empty, and
call place ( and ._sf) only if it is non-empty. ouput has only
self.badvalue, so returning output without a call to _sf might work
correctly.
As a note: I don't think we have tests for any of the methods if all
values are outside, but cdf seems to work
{{{
>>> stats.hypergeom.cdf(5,10,2,5)
1.0
>>> stats.hypergeom.cdf(-5,10,2,5)
0.0
}}}
So it might also be possible to check how cdf manages empty *goodargs.
--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1291#comment:4>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
More information about the Scipy-tickets
mailing list