-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
dist_math.incomplete_beta is very slow #4420
Comments
Looking at this #4454 CI run: https://github.com/pymc-devs/pymc3/pull/4454/checks?check_run_id=1807188616 The top 5 slowest distribution tests include all of the ones mentioned above (with the notable exception of the StudentT) and together took nearly 1 hour to complete. |
The |
Is the gradient available? Looks like it might be much faster create a theano Op to call scipy directly similar to |
I am not sure about the gradient, I will do some research. If anyone knows please chime in :) |
I found some formulae for the partial derivatives here: https://functions.wolfram.com/GammaBetaErf/Beta3/20/01/ The partial derivative with respect to x is trivial (given the beta is defined as an integral up to x) The partial derivatives with respect to a, and b are more tricky. They require the Hypergeometric function 3F2, which is not given by scipy AFAIK. It seems to exist in mpmath though: https://mpmath.org/doc/current/functions/hypergeometric.html#hyp3f2. |
…tive derivatives Closes pymc-devs#4420
…tive derivatives Closes pymc-devs#4420
…tive derivatives Closes pymc-devs#4420
I notice this when running test_distributions.py. Any distribution
logcdf
method that usesincomplete_beta
takes ages to run.Right now it is used in the
logcdf
methods ofBeta
,StudentT
,Binomial
,NegativeBinomial
, andZeroInflated
versions of the last two distributions.Is there a reason why this cannot be implemented as a Theano C Op? Scipy has C implementation here, which seems to be doing exactly the same as our algorithm in
dist_math.py
:https://github.com/scipy/scipy/blob/master/scipy/special/cephes/incbet.c
In addition, this would probably make it trivial to implement a vectorized version for tensors, allowing the logcdf methods of the distributions above to evaluate more than one value at a time.
The text was updated successfully, but these errors were encountered: