def _compute_prior_log_p(self, alpha, partition): log_p = partition.number_of_cells * log(alpha) for n_c in partition.counts: log_p += log_gamma(n_c) n = partition.number_of_items for i in range(1, n + 1): log_p -= log_gamma(alpha + i - 1) return log_p
def log_factorial(n): return log_gamma(n + 1)
def log_beta(a, b): if a <= 0 or b <= 0: return float('-inf') return log_gamma(a) + log_gamma(b) - log_gamma(a + b)
def log_gamma_pdf(x, a, b): return -log_gamma(a) + a * log(b) + (a - 1) * log(x) - b * x
def log_beta(a, b): if a <= 0 or b <= 0: return -np.inf return log_gamma(a) + log_gamma(b) - log_gamma(a + b)