Skip to content

Support logp derivation of power(base, rv) #6962

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

Merged
merged 13 commits into from
Oct 26, 2023

Conversation

LukeLB
Copy link
Contributor

@LukeLB LukeLB commented Oct 19, 2023

Addresses the first case in #6896, allowing users to evaluate the log prob of generalised bases e.g, power(base, x). This constricts base to be either a constant or a continuous random variable as long as its vaue is greater or equal to 0.

I've added a node rewrite function to deal with the power(base, x) case. To make sure that power(x, exponent) is unaffected by this rewrite I have made changes to find_measurable_transform. This is based upon the ordering of the node inputs which is assumed to always be node.inputs = [base, exponent], where the new rewrite takes the case where index 1 is measurable and PowerTransform takes the case where index 0 is measurable.

Closes #6896
...

Checklist

New features

  • Allows users to evaluate the logp of a generalised power(base, x) or base**x

📚 Documentation preview 📚: https://pymc--6962.org.readthedocs.build/en/6962/

@codecov
Copy link

codecov bot commented Oct 19, 2023

Codecov Report

Merging #6962 (fc3129a) into main (6f4a040) will decrease coverage by 0.08%.
Report is 13 commits behind head on main.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6962      +/-   ##
==========================================
- Coverage   92.18%   92.11%   -0.08%     
==========================================
  Files         100      100              
  Lines       16847    16896      +49     
==========================================
+ Hits        15531    15563      +32     
- Misses       1316     1333      +17     
Files Coverage Δ
pymc/logprob/transforms.py 94.97% <100.00%> (+0.06%) ⬆️

... and 8 files with indirect coverage changes

Copy link
Member

@ricardoV94 ricardoV94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks amazing!!!

Just some small suggestions for comments / tests, but nothing about the fundamentals

@ricardoV94 ricardoV94 changed the title Support logp derivation of power(base, x) Support logp derivation of power(base, rv) Oct 20, 2023
@ricardoV94 ricardoV94 merged commit 419af06 into pymc-devs:main Oct 26, 2023
@ricardoV94
Copy link
Member

Thanks @LukeLB, sounds line we nailed all these Elemwise transforms?

@LukeLB
Copy link
Contributor Author

LukeLB commented Oct 27, 2023

Cheers! Yep all done💥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support logp derivation of power exponent
2 participants