stan-dev / stan-dev/math

Feature request: permit location of 0/negative_infinity() in neg_binomial_2(_log)_lpmf

Open
#3,302 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

distributions good first issue numerics
Dominant language
C++
Stars
839
Forks
220
Avg merge
2d 4h
Merged PRs (30d)
14

Description

Good day,

It is currently possible to have location parameter of 0 in poisson_lpmf and negative_infinity() in poisson_log_lpmf; I've also verified this works with the _glm functions:

model {
  real works = poisson_lpmf(1 | 0),
       works2 = poisson_log_lpmf(1 | negative_infinity());
}

However, this is not possible with neg_binomial_2 functions:

model {
  real fails = neg_binomial_2_lpmf(1 | 0, 1),
       fails2 = neg_binomial_2_log_lpmf(1 | negative_infinity(), 1);
}

which errors out with:

Exception: neg_binomial_2_lpmf: Location parameter is 0, but must be positive finite!

I think it would be reasonable to permit similar behaviour as for the Poisson functions?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the neg_binomial_2_lpmf and neg_binomial_2_log_lpmf entry points, and compare their location validation with poisson_lpmf and poisson_log_lpmf. Done means the negative-binomial functions accept the requested zero and negative_infinity() cases consistently with the Poisson functions, with the relevant behavior covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.