def _get_statistics(self,data):
# NOTE: since this isn't really in exponential family, this method needs
# to look at hyperparameters. form posterior hyperparameters for the p
# parameters here so we can integrate them out and get the r statistics
n, tot = super(NegativeBinomialIntegerR,self)._get_statistics(data)
if n > 0:
alpha_n, betas_n = self.alpha_0 + tot, self.beta_0 + self.r_support*n
data = flattendata(data)
log_marg_likelihoods = \
special.betaln(alpha_n, betas_n) \
- special.betaln(self.alpha_0, self.beta_0) \
+ (special.gammaln(data[:,na]+self.r_support)
- special.gammaln(data[:,na]+1) \
- special.gammaln(self.r_support)).sum(0)
else:
log_marg_likelihoods = np.zeros_like(self.r_support)
return n, tot, log_marg_likelihoods
评论列表
文章目录