-
-
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
Add icdf functions for Beta, Gamma, Chisquared and StudentT distributions #6845
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6845 +/- ##
==========================================
- Coverage 92.29% 90.97% -1.33%
==========================================
Files 100 100
Lines 16875 16887 +12
==========================================
- Hits 15575 15363 -212
- Misses 1300 1524 +224
|
@ricardoV94 now that pymc-devs/pytensor#502 is merged, we are able to complete this PR. The tests are failing because Let me know what you think. |
You can see which PyTensor version is being installed in the CI. |
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.
Couple more comments. Looks great otherwise
Yeah it's strange it's still installing 2.18.4, even though 2.18.5 was released already some days ago. We may need to be just a bit more patient? |
Right! That's what I thought, I saw the pytenor release 4 days ago and thought it was a good experience to try it now and see if the update immediately applies. No rush on it, it will work soon. |
e971c9d
to
11942b9
Compare
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
c1d3d35
to
babc479
Compare
@maresb any idea why CI is not yet installing the last PyTensor? Was there an issue on the conda side? |
There was a glitch in the deployment of 2.18.5 to anaconda.org. I reran it, so hopefully it fixes things. |
It uploaded successfully on anaconda.org, so I restarted the tests. |
Interesting way to restart the tests! I searched for and the recommendation I found was to push an empty commit, but I think this is nicer. |
You can also just ask a dev with write permissions. We can restart them from GitHub interface |
Is the nan coming from |
Sounds like PyTensor gammainc C code does not have a special case for np.inf: In contrast this scipy has a special case? |
Indeed, this code returns nan. I tried to fix it writing the special case for np.inf in the `DEVICE double GammaP (double n, double x) /--------------------------------------------------------------------/ DEVICE double GammaQ (double n, double x) Even with this, the |
You need to delete pytensor cache or bump the Op c_cache_version number. Try |
Thanks for the pointers! You were on point in all suggestions, the logcdf problem and the solution to it. After changing the gamma.c function and I will open an issue and a PR in pytensor to change the |
That PR should probably do a similar fix for the complementary gammainc function (gammaincc?) Edit: I see you were already onto it |
@amyoshino PyTensor new release should be in conda soon. We will need to update the pin on PyTensor version here, as it was a "major" release (or in a separate PR if there are other things that need fix) https://github.com/pymc-devs/pytensor/releases/tag/rel-2.19.0 |
That's awesome!! Looking forward to it to be updated! |
You need to bump the PyTensor dependency constraints on the PyMC side |
Ah, I see! Alright, let me try that then! Thanks for the pointer. |
Just pushed the bump dependency modifications in here. Seems like there is one test failing though, which wasn't failing when I ran the test suite locally. |
@amyoshino I'm taking core of the Pytensor bump in #7203 |
May have been an unlucky seed, rerunning it |
9f4352e
to
262d868
Compare
In much better hands now 😄
It was indeed a bad luck, the only failing part was the mypy, I guess because of the very outdated repo. I rebased and left only the previous commits here, so it is failing now because PyTensor is still 2.18. I think the way to go then is to wait for your PR to be merged and try again, right? |
Right. I was hoping it was an easier bump, but it also unpins a Python major version :D |
Cool! It looks like the bump is merged! Looking forward to restart the checks when you think is appropriate. |
You can rebase anytime to incorporate the bump |
Ah, true! I got so excited that the bump was merged and this potentially can be merged after so long that I forgot that 😅 My apologies haha EDIT: Good news! I think it is ready to go now |
…ions removing unnecessary parameterization test on studentT test removing unnecessary test on chisquared test
…check_icdf_parameters
262d868
to
00c1f34
Compare
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.
Amazing work @amyoshino !!
Congrats, this was a tricky one! |
That was fun! 😄 |
What is this PR about?
Adds ICDF functions to Beta, Gamma, Chisquared and StudentT distributions.
Issue #6612
This is a work in progress. The quantile functions depend on two main functions:
betaincinv
gammaincinv
Those are implemented in SciPy but not in Pytensor yet. When importing the two functions from
scipy.special
and plugging them in the desired formula, I get aTypeError
like this below:"TypeError: ufunc 'betaincinv' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''"
It looks like the most straightforward way to make these icdf functions work is to implement them in Pytensor, in the same way the
pt.betainc
has been implementedAny comments about if this is the right path? If so I am happy to open an issue in Pytensor as a feature request, and possibly helping on its development if nobody else wants to take it. But if there is any ideas on how to make it simpler than that, let me know.
References:
Checklist
Major / Breaking Changes
New features
Bugfixes
Documentation
Maintenance
📚 Documentation preview 📚: https://pymc--6845.org.readthedocs.build/en/6845/