Skip to content

Restore NB2 zero-mean padding in NegativeBinomial observation paths#831

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-negative-binomial-padding
Draft

Restore NB2 zero-mean padding in NegativeBinomial observation paths#831
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-negative-binomial-padding

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

Zero-mean NegativeBinomial2 support in upstream Poisson handling did not resolve NB2 behavior in PyRenew’s observation paths. NegativeBinomialNoise and NegativeBinomialObservation still produced invalid (NaN) log-probabilities at exact zero means.

  • Regression coverage for zero-mean NB2

    • Added focused tests for both APIs to assert finite log-probability when mean == 0 and obs == 0.
    • This closes the test gap that allowed the previous zero-padding removal to pass.
  • Reintroduced epsilon mean padding in NB2 call sites

    • pyrenew/observation/noise.py (NegativeBinomialNoise.sample)
    • pyrenew/observation/negativebinomial.py (NegativeBinomialObservation.sample)
    • Both now apply epsilon padding before constructing dist.NegativeBinomial2.
  • Documented numerical-stability rationale inline

    • Added short comments at both call sites explaining why padding is required.
padded_mean = jnp.asarray(mu) + jnp.finfo(float).eps
dist.NegativeBinomial2(mean=padded_mean, concentration=concentration)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • releases.astral.sh
    • Triggering command: /home/REDACTED/.local/bin/uv /home/REDACTED/.local/bin/uv sync (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI and others added 2 commits May 19, 2026 21:52
Agent-Logs-Url: https://github.com/CDCgov/PyRenew/sessions/3e268fdd-875d-42cb-8928-98bb74275032

Co-authored-by: dylanhmorris <8032117+dylanhmorris@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix negative binomial tests and add zero-padding Restore NB2 zero-mean padding in NegativeBinomial observation paths May 19, 2026
Copilot AI requested a review from dylanhmorris May 19, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: NegativeBinomial2 means still need zero-padding

2 participants