Skip to content

Conversation

@ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Nov 10, 2025

I was going to work on general icdf(abs(x)) which requires an optimization routine, but found some small crumbs along the way.

  • Allow logp(abs(x)) and logcdf(abs(x)) for discrete x.
  • Fix logcdf of DiscreteUniform for x == lower
  • Handle special case in logdiffexp(-inf, -inf) so it can be safely used in more contexts

ndim_supp = value.ndim - input_logprob.ndim
jacobian = jacobian.sum(axis=tuple(range(-ndim_supp, 0)))

# Discrete transformations do not need the jacobian adjustment
Copy link
Member Author

Choose a reason for hiding this comment

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

We don't really support any discrete cases with det(jacobian) != 1 but I prefer to have this branch already

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.46%. Comparing base (1c0be8f) to head (474c8b7).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7958      +/-   ##
==========================================
- Coverage   91.48%   91.46%   -0.02%     
==========================================
  Files         116      116              
  Lines       18935    18957      +22     
==========================================
+ Hits        17322    17339      +17     
- Misses       1613     1618       +5     
Files with missing lines Coverage Δ
pymc/distributions/discrete.py 99.42% <ø> (ø)
pymc/logprob/transforms.py 95.03% <100.00%> (-0.40%) ⬇️
pymc/math.py 74.17% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@jessegrabowski jessegrabowski left a comment

Choose a reason for hiding this comment

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

I found a typo! I'm helping!

else:
x_rv = pt.abs(DiscreteUniform.dist(-4, 4, size=(5,)))
# |x_rv| = DiscreteUniform(0,4) with P(X=0) halved relative to other values
# We can use a Categorical to representh this
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# We can use a Categorical to representh this
# We can use a Categorical to represent this

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.

2 participants