def init(self, shared, group=None): if group is None: self.p = sample_beta(shared.alpha, shared.beta) else: alpha = shared.alpha + group.heads beta = shared.beta + group.tails self.p = sample_beta(alpha, beta)
def add_value(self, value): assert value != OTHER, 'cannot add OTHER' count = self.counts.get(value, 0) + 1 self.counts[value] = count if count == 1: beta = self.beta0 * sample_beta(1.0, self.gamma) self.beta0 = max(0.0, self.beta0 - beta) self.betas[value] = beta
def init(self, shared, group=None): post = shared if group is None else shared.plus_group(group) self.p = sample_beta(post.alpha, post.beta)
def init(self, shared): self.heads = 0 self.tails = 0 self.p = sample_beta(shared.alpha, shared.beta)
def init(self, shared, group=None): if group is None: self.p = sample_beta(shared.alpha, shared.beta) else: self.p = group.p