def sample_cell_values(data, partition, base_measure):
    for cell in partition.cells:
        a = base_measure.a
        b = base_measure.b

        for item in cell.items:
            a += data[item][0]
            b += data[item][1] - data[item][0]

        cell.value = beta_rvs(a, b)
Пример #2
0
def beta_proposal(m):
    if m == 0 or m == 1:
        return random.random()

    s = 10

    a = s * m
    b = s - a

    if a <= 0:
        a = 1e-100
    if b <= 0:
        b = 1e-100

    return beta_rvs(a, b)
 def random(self):
     return beta_rvs(self.a, self.b)
Пример #4
0
def beta_binomial_rvs(n, a, b):
    p = beta_rvs(a, b)

    x = binomial_rvs(n, p)

    return x