Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
def log_factorial(n):
    return log_gamma(n + 1)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
def log_gamma_pdf(x, a, b):
    return -log_gamma(a) + a * log(b) + (a - 1) * log(x) - b * x
Ejemplo n.º 6
0
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)