A -sided die has unknown face probabilities with a Dirichlet prior . After observing counts of each face the posterior is with . Implement:
dirichlet_posterior(counts, alpha) returning (alpha_post, mean, mode) as numpy arrays: the posterior parameters, the posterior mean (which is also the posterior predictive ), and the MAP estimate
Return None for the mode when some or when .log_evidence(counts, alpha): the log marginal likelihood of one particular sequence with these counts,
log_predictive_batch(counts, alpha, future_counts): the log probability of one particular future sequence with counts future_counts, given the past data, .alpha is either a scalar (the same value for every face) or an array of length . Use math.lgamma (or numpy) for the log-gamma function.