示例#1
0
def execute_C(x):
    noisy_counts = real_counts.copy()
    # print(noisy_counts)
    # print(x)
    noisy_counts[x] = noisy_counts[x] + 1  # Add the disease to the count
    # print("///////////////")
    # print(x)
    # print(real_counts)
    # print(noisy_counts)
    # print("///////////////")

    for d in range(real_counts.size):
        cnt = noisy_counts[d] - range_start  # 0-based count for x
        # geom_cnt_row = np.array(Geom[cnt, :])
        # print(geom_cnt_row)
        noisy_counts[d] = probab.draw(
            Geom[cnt, :]) + range_start  # draw a noisy count from Geom's cnt-th row, map back to the real range

        # rndmstt = create_new_rndm_state()
        # obs = np.arange(start=range_start, stop=range_start + range_size, step=1)
        # # print(len(obs))
        # # print(len(Geom[cnt, :]))
        # sample_distr = stats.rv_discrete(name='draw', values=(obs, Geom[cnt, :]), seed=rndmstt)
        #
        # noisy_counts[d] = sample_distr.rvs(size=1, random_state=rndmstt)

    return noisy_counts
示例#2
0
def create_single_dataset(size, C):
    samples_list = []
    for i in range(size):
        x = probab.draw(pi)
        y = execute_C(x, C)
        samples_list.append([y, x])

    return np.array(samples_list).reshape((size, len(samples_list[0])))
示例#3
0
def draw_x_y():
    # pi_ = np.array(pi)
    x = probab.draw(pi)
    return x, execute_C(x)
示例#4
0
def execute_C(
    x, C
):  # we only have black box access to C. This function runs C under secret x and returns an output y
    # C_x = np.array(C[x, :])
    return probab.draw(C[x, :])