-
-
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
Derive logprob of <
and >
operations
#6662
Derive logprob of <
and >
operations
#6662
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6662 +/- ##
==========================================
+ Coverage 91.97% 91.99% +0.01%
==========================================
Files 94 95 +1
Lines 15942 16000 +58
==========================================
+ Hits 14663 14719 +56
- Misses 1279 1281 +2
|
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 is awesome!
I left some comments below, but I think it's nearly there.
04998ec
to
6b40e55
Compare
@ricardoV94 I have made the suggested changes and I just wanted to confirm the approach before adding a test for the separate function |
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.
Looks good! Wanna tackle >=
and <=
next?
Definitely! Although I was wondering if |
Yes if you allow either direction in |
We can make this PR process expressions like But this may require adding a transform for I think it may be better to simply add separate derivations of LE and GE like in this PR. |
You can see that for other MeasurableElemwise like pymc/pymc/logprob/transforms.py Line 348 in 1ed4475
|
Sure, I'll look into this approach. Meanwhile, I had a question about the expression used in this PR to calculate logprob for discrete distributions. I think I should correct it to the following (please correct me if I've misunderstood)
|
For discrete variables the CDF gives us the probability <=, so yes. You can do |
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.
Flagging it so we don't merge with the wrong logp by accident
a5c48c2
to
19ab8ad
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.
Looks great
I went through pymc/pymc/logprob/transforms.py Lines 556 to 562 in 61be336
We then make a pymc/pymc/logprob/transforms.py Lines 585 to 586 in 61be336
|
You're right, so maybe we don't need it at all? Just make it so the first input is always the measurable one? |
<
and >
than comparisons
<
and >
than comparisons<
and >
comparisons
<
and >
comparisons<
and >
operations
This PR implements the logprob inference for binary comparison Ops
>
and<
.It creates a MeasurableComparison variable and evaluates the logprob based on the truth value of the condition.
Addresses #6633.
Checklist
New features
📚 Documentation preview 📚: https://pymc--6662.org.readthedocs.build/en/6662/