def random(self, params): a, b = self._get_standard_params(params) a += 1 b += 1 return BetaData(beta_rvs(a, b))
def sample_atom(self, data, cell): a = self.base_measure.params.a b = self.base_measure.params.b for item in cell.items: a += data[item].x b += data[item].n - data[item].x return BetaData(beta_rvs(a, b))
def sample(self, old_value, num_clusters, num_data_points): a = self.a b = self.b k = num_clusters n = num_data_points eta = beta_rvs(old_value + 1, n) x = (a + k - 1) / (n * (b - log(eta))) pi = x / (1 + x) label = discrete_rvs([pi, 1 - pi]) scale = b - log(eta) if label == 0: new_value = gamma_rvs(a + k, scale) else: new_value = gamma_rvs(a + k - 1, scale) return new_value
def random(self): x = beta_rvs(self.params.a, self.params.b) return BetaData(x)