[Scipy-tickets] [SciPy] #1421: scipy.stats.poisson has wrong documentation
SciPy Trac
scipy-tickets@scipy....
Sat Feb 4 20:16:41 CST 2012
#1421: scipy.stats.poisson has wrong documentation
---------------------------+------------------------------------------------
Reporter: schwarz | Owner: pv
Type: defect | Status: needs_review
Priority: normal | Milestone: Unscheduled
Component: Documentation | Version: 0.9.0
Keywords: |
---------------------------+------------------------------------------------
Comment(by josefpktd):
about ppf: I don't see anything wrong
see definition
http://docs.scipy.org/doc/scipy/reference/tutorial/stats/discrete.html
#percent-point-function-inverse-cdf
ppf(q) = min{x : cdf(x) >= q}
{{{
>>> from scipy.stats import hypergeom
>>> [M, n, N] = [20, 7, 12]
}}}
using cdf values for range(4), we should get ppf = range(4) back
{{{
>>> x = np.arange(4)
>>> prb = hypergeom.cdf(x, M, n, N)
>>> prb
array([ 0.0001031991744066, 0.004437564499484 , 0.0521155830753351,
0.2507739938080476])
>>> hypergeom.pmf(x, M, n, N)
array([ 0.0001031991744066, 0.0043343653250774, 0.0476780185758511,
0.1986584107327126])
>>> hypergeom.ppf(prb, M, n, N)
array([ 0., 1., 2., 3.])
}}}
if we use the cdf at other points, the ppf should give us those back,
roundtripping
{{{
>>> x = np.arange(4)*2
>>> x
array([0, 2, 4, 6])
>>> prb = hypergeom.cdf(x, M, n, N)
>>> prb
array([ 0.0001031991744066, 0.0521155830753351, 0.6083591331269301,
0.9897832817337386])
>>> hypergeom.ppf(prb, M, n, N)
array([ 0., 2., 4., 6.])
}}}
If we use values that are not at the kinks of the cdf step function, we
get the next higher quantile back. (I always have to draw a step function
as example and check the definition. But this looks ok to me. I know it
took me a while to convince myself of this in my first round with
scipy.stats.distributions.
{{{
>>> hypergeom.ppf(prb+1e-8, M, n, N)
array([ 1., 3., 5., 7.])
>>> hypergeom.ppf(prb-1e-8, M, n, N)
array([ 0., 2., 4., 6.])
}}}
as reference
change in commit
https://github.com/rgommers/scipy/commit/7d608b2640495e10441d7f21bae3a214b386e2da
looks good
I have problems accessing other tickets right now, but a suggestion for
which I opened another ticket is to expand the generic docs to include the
example parameters from the test suite. This way we could write generic
examples which work for each distribution. But I haven't looked how
difficult this would be.
--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1421#comment:8>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
More information about the Scipy-tickets
mailing list