-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Fixes gh-7491, pdf at x=0 of fisk/burr/burr12/f distributions. #10381
Conversation
Enable computation of pdf, logpdf at left-hand end points of fisk, burr, burr12 and f distrbutions. Fixes scipygh-7491 and half of scipygh-9544. Incorporate scipygh-9978 from rlucas7 to address scipygh-9544. Updated docstring of burr distribution. Added tutorial for stats.burr12. Removed an ignored implementation of fisk._stats(). In stats.burr.{pdf,logpdf} replaced two separate long code blocks with a simpler _lazywhere. Explicitly handle c<=n in stats.burr._munp(). Added checking of pdf-logpdf consistency to stats.test_continuous_basic.py. Added a filter for stats.recipinvgauss in check_pdf_logpdf(). Added any finite distribution endpoints to list of x-values checked in {check_pdf_logpdf, check_sf_logsf, check_cdf_logcdf}. Added another test case to test_burr_stats_9544().
f2 = lambda x_, c_, d_: (c_ * d_ * (x_ ** (-c_ - 1.0)) / | ||
((1 + x_ ** (-c_)) ** (d_ + 1.0)))) | ||
if output.ndim == 0: | ||
return output[()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed here, since this squeezing is done at the rv_generic.pdf
anyway. Can be done as a follow-up though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all calls to ._pdf
originate from inside .pdf()
. rv_continuous._cdf_single()
calls integrate.quad(self._pdf, ...)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many other distribution do not have this clause. Is it a bug in them all? Or is it a bug in _cdf_single?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
integrate.quad
passes in scalars to self._pdf
and expects a scalar back.
burr._pdf(self, x, c, d)
has a conditional. It does this by invoking _lazywhere(...)
, and _lazywhere
always returns an array, even if all its inputs are scalars. Hence the squeeze.
The _pdf
of most distributions makes calls to numpy
or scipy
ufuncs which return a scalar if given scalars, so this issue doesn't affect them.
+ sc.xlogy(-c_ - 1, x_) | ||
- sc.xlog1py(d_+1, x_**(-c_)))) | ||
if output.ndim == 0: | ||
return output[()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
Thanks @pvanmulbregt, @rlucas7, LGTM modulo nitpicks which can be addressed in a separate cleanup. Merged. |
Replaces gh-9983 (rebase had trouble merging with gh-10154 --- this PR applies the same modifications manually to current master.)
Enable computation of
pdf
,logpdf
at left-hand end points offisk
,burr
,burr12
andf
distrbutions. Fixes gh-7491 and half of gh-9544.Incorporate gh-9978 from @rlucas7 to address gh-9544.
Updated docstring of
stats.burr
distribution.Added tutorial for
stats.burr12
.Removed an ignored implementation of
fisk._stats()
.In
stats.burr.{pdf,logpdf}
replaced two separate long code blocks with a simpler_lazywhere
.Explicitly handle
c<=n
instats.burr._munp()
.Added consistency checking of
pdf
andlogpdf
tostats.test_continuous_basic.py
.Added a filter for
stats.recipinvgauss
incheck_pdf_logpdf()
.Added any finite distribution endpoints to list of x-values checked in
{check_pdf_logpdf, check_sf_logsf, check_cdf_logcdf}
.Added another test case to
test_burr_stats_9544()
.