fix(distributions): handle zero-mean negative binomial - #2256
Conversation
Benchmark reportthis PR + run time: 1 faster
compile time: unchanged across 32 benchmarksSignificant changes (1) ─────── run time ─────── ───── compile time ─────
benchmark baseline this PR Δ baseline this PR Δ
──────────────────────────────────────────────────────────────────────────────
+ categorical_log_prob 2.2 ms 2.0 ms -6.2% 73.0 ms 73.1 ms +0.0%Red is slower, green is faster; a row is coloured by the worse of its two columns. A delta in parentheses cleared the threshold on a measurement below the resolution floor, so it is shown without being called a change. † marks a benchmark that could not be compared — see below. Full results
|
| baseline | this PR | |
|---|---|---|
| ref | master |
fix/negative-binomial-zero-mean |
| commit | 0059d3af |
9236dc47 |
| numpyro | 0.21.0 | 0.21.0 |
| jax | 0.11.1 | 0.11.1 |
| backend | cpu | cpu |
| python | 3.14.7 | 3.14.7 |
Runner: Linux-6.17.0-1022-azure-x86_64-with-glibc2.39, 4 CPUs.
Produced by this benchmark run.
Summary
HurdleNegativeBinomial2.Fixes #2193
Tests
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .\.venv\Scripts\python.exe -m pytest -q test/test_distributions.py -k 'zero_mean_negative_binomial or negative_binomial_log_prob_gradient or hurdle_negative_binomial_requires_positive_mean or gamma_poisson_mixed_finite_and_infinite_rates or gamma_poisson_log_prob or test_log_prob_gradient and (GammaPoisson or NegativeBinomial)'(27 passed)PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .\.venv\Scripts\python.exe -m pytest -q test/test_distributions.py -k 'HurdleNegativeBinomial2'(5 passed)py -3.13 -m ruff check numpyro/distributions/conjugate.py test/test_distributions.pypy -3.13 -m ruff format --check numpyro/distributions/conjugate.py test/test_distributions.pyAI assistance disclosure: AI-assisted development tools were used during investigation and implementation. The reported tests were run against the final diff.