Skip to content

The way neg_binomial_2_lpmf delegates to Poisson is broken #1496

Description

@martinmodrak

Description

The neg_binomial_2_lpmf delegates to poisson_lpmf for large values of the phi parameter. Currently the cutoff is set at phi > 1e5. This introduces discontinuities into the function - I am nut sure whether this is because the cutoff is too optimistic or too pessimistic.

Example

neg_binomial_2_lpmf(181, 13, 1e5 - 1e-8) == -312.05065787932836
neg_binomial_2_lpmf(181, 13, 1e5 + 1e-8) == -312.19077641210203

neg_binomial_2_lpmf(121358, 13, 1e5 - 1e-8) == -933542.7362432084
neg_binomial_2_lpmf(121358, 13, 1e5 + 1e-8) == -988062.09132748179

I've written a failing test for the cutoff at: develop...martinmodrak:bugfix/1496-poisson-phi-cutoff

Expected Output

Values at cutoff - 1e-8 and cutoff + 1e-8 are almost constant, i.e. changes in phi no longer influence the lpmf value and delegating to Poisson is safe.

Current Version:

v3.0.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions