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.
Specifically the following lines
cgpm/src/primitives/poisson.py
Lines 146 to 170 in 46e1d8d
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.