Skip to content

Investigate suspicious implementation of Poisson.logpdf #251

Description

@fsaad

Specifically the following lines

@staticmethod
def calc_predictive_logp(x, N, sum_x, a, b):
an, bn = Poisson.posterior_hypers(N, sum_x, a, b)
am, bm = Poisson.posterior_hypers(N+1, sum_x+x, a, b)
ZN = Poisson.calc_log_Z(an, bn)
ZM = Poisson.calc_log_Z(am, bm)
return ZM - ZN - gammaln(x+1)
@staticmethod
def calc_logpdf_marginal(N, sum_x, sum_log_fact_x, a, b):
an, bn = Poisson.posterior_hypers(N, sum_x, a, b)
Z0 = Poisson.calc_log_Z(a, b)
ZN = Poisson.calc_log_Z(an, bn)
return ZN - Z0 - sum_log_fact_x
@staticmethod
def posterior_hypers(N, sum_x, a, b):
an = a + sum_x
bn = b + N
return an, bn
@staticmethod
def calc_log_Z(a, b):
Z = gammaln(a) - a*log(b)
return Z

The posterior predictive distribution should be a negative binomial with n = a' and p = 1 / (1 + b'), or possibly p = 1 - 1/(1+b'), depending on the parameterization. From a cursory test the values returned by Poisson.calc_predictive_logp do not correspond to the negative binomial probabilities from scipy.stats.nbinom.

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions