Skip to content

Add Poisson and NegativeBinomial to pymc.dims#8305

Merged
ricardoV94 merged 3 commits into
pymc-devs:mainfrom
williambdean:wdb/bass-dims-distributions
May 20, 2026
Merged

Add Poisson and NegativeBinomial to pymc.dims#8305
ricardoV94 merged 3 commits into
pymc-devs:mainfrom
williambdean:wdb/bass-dims-distributions

Conversation

@williambdean
Copy link
Copy Markdown
Contributor

Summary

Add Poisson and NegativeBinomial to pymc.dims to unblock the Bass model dimension migration (pymc-labs/pymc-marketing#2598). These are the last two distributions needed before the Bass model can migrate from create_dim_handler to the xdist=True / pymc.dims pattern used by the rest of pymc-marketing.

Changes

  • pymc/dims/distributions/scalar.py: Add Poisson (wraps ptxr.poisson, accepts mu) and NegativeBinomial (wraps ptxr.nbinom, accepts mu/alpha or n/p parameterization) as DimDistribution subclasses

  • tests/dims/distributions/test_scalar.py: Add test_poisson and test_negative_binomial following the existing pattern — create a model with the dims distribution + reference model with the regular distribution, assert equivalent random and logp graphs

Background

These are the first discrete count distributions in pymc.dims. Poisson is the default likelihood for the Bass model, and NegativeBinomial is the alternative. DiracDelta is out of scope (can be handled by supporting non-Prior configurations in pymc-marketing).

The underlying PyTensor xtensor operations (ptxr.poisson, ptxr.nbinom) already existed — only the pymc.dims wrapper classes were missing.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.73%. Comparing base (88dc395) to head (cb0bf6b).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8305      +/-   ##
==========================================
- Coverage   91.77%   91.73%   -0.05%     
==========================================
  Files         125      125              
  Lines       20437    20471      +34     
==========================================
+ Hits        18757    18779      +22     
- Misses       1680     1692      +12     
Files with missing lines Coverage Δ
pymc/dims/distributions/scalar.py 96.85% <100.00%> (+0.24%) ⬆️

... and 2 files with indirect coverage changes

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

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented May 18, 2026

Documentation build overview

📚 pymc | 🛠️ Build #32775369 | 📁 Comparing cb0bf6b against latest (88dc395)

  🔍 Preview build  

2 files changed
± glossary.html
± _modules/pymc/dims/distributions/scalar.html

Comment thread pymc/dims/distributions/scalar.py Outdated
Copy link
Copy Markdown
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.

LGTM but I would make the alternative parameters keyword only

Co-authored-by: Ricardo Vieira <28983449+ricardoV94@users.noreply.github.com>
@ricardoV94 ricardoV94 merged commit f09f6b6 into pymc-devs:main May 20, 2026
42 checks passed
@ricardoV94
Copy link
Copy Markdown
Member

thanks

@williambdean williambdean deleted the wdb/bass-dims-distributions branch May 21, 2026 10:21
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