Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate suspicious implementation of Poisson.logpdf #251

Open
fsaad opened this issue Apr 9, 2020 · 0 comments
Open

Investigate suspicious implementation of Poisson.logpdf #251

fsaad opened this issue Apr 9, 2020 · 0 comments

Comments

@fsaad
Copy link
Collaborator

fsaad commented Apr 9, 2020

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.

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

No branches or pull requests

1 participant