Beispiel #1
0
def getProb(clique, bit_list, bit_cand_list, row_list, bitsum_list, f, dt):
    leng = len(clique)
    pro = []
    att_index1 = clique[0]
    att_indexs = clique[1:(leng)]
    att_rappor_list_combine, att_signal_list_combine, att_row_list_combine = att_combin(
        bit_list, bit_cand_list, row_list, att_indexs)
    proe = estimate_2d(bit_list[att_index1], att_rappor_list_combine,
                       bit_cand_list[att_index1], att_signal_list_combine,
                       bitsum_list, clique, f, dt)
    proleng = len(proe)
    for i in range(proleng):
        pro.extend(proe[i])
    some_list = list_product(row_list[clique[0]], att_row_list_combine)
    return [some_list, pro], proe
Beispiel #2
0
def independent_marginal3(clique, bit_list, bit_cand_list, row_list,
                          bitsum_list, f, dt):
    ##################################################################
    # To generate independent probability and possible list for sampling
    leng = len(clique)
    pro = []
    some_list = []
    if leng <= 2:
        att_index1 = clique[0]
        att_index2 = clique[leng - 1]
        #proe=estimate_2d(bit_list[att_index1], bit_list[att_index2], bit_cand_list[att_index1], bit_cand_list[att_index2], f, dt)
        proe = estimate_2d6(bit_list[att_index1], bit_list[att_index2],
                            bit_cand_list[att_index1],
                            bit_cand_list[att_index2], bitsum_list, clique, f,
                            dt)
        proleng = len(proe)
        for i in range(proleng):
            pro.extend(proe[i])
        some_list = row_list[clique[0]]

    else:
        att_index1 = clique[0]
        att_indexs = clique[1:(leng)]
        #print(att_index1)
        #print(att_indexs)
        att_rappor_list_combine, att_signal_list_combine, att_row_list_combine = att_combin(
            bit_list, bit_cand_list, row_list, att_indexs)
        #print('rowlist combine',att_row_list_combine)    att_combin(bit_list,bit_cand_list,row_list,att_indexs)
        #print(att_row_list_combine)
        #proe=estimate_2d2(bit_cand_list[att_index1],att_signal_list_combine,bitsum_list,clique)
        proe = estimate_2d6(bit_list[att_index1], att_rappor_list_combine,
                            bit_cand_list[att_index1], att_signal_list_combine,
                            bitsum_list, clique, f, dt)
        proleng = len(proe)
        for i in range(proleng):
            pro.extend(proe[i])
        some_list = list_product(row_list[clique[0]], att_row_list_combine)
        #print('estimate:',proe)
    return some_list, pro
Beispiel #3
0
def pair_independe_draw(new_data_list, origin_node_num, clique, p_single_list,
                        p_comb_list, row_list):
    leng = len(clique)
    if leng == 1:
        some_list = row_list[clique[0]]
        pro = p_single_list[clique[0]]
        for i in range(origin_node_num):
            items = independent_random_pick(some_list, pro)
            new_data_list[i][clique[0]] = items
    else:
        initial_flag = 0
        for i_clique in range(leng - 1):
            j_clique = i_clique + 1

            condition_list, some_list, pro = pairwise_conditional_margin(
                clique[i_clique], clique[j_clique], p_comb_list, row_list)
            #print('pro:',pro,some_list)
            if initial_flag == 0:
                initial_flag = 1
                some_list2 = list_product(condition_list, some_list)
                pro2 = pro[0] + pro[1]
                for i in range(origin_node_num):
                    item = independent_random_pick(some_list2, pro2)
                    new_data_list[i][clique[i_clique]] = item[0]
                    new_data_list[i][clique[j_clique]] = item[1]
            else:
                for i in range(origin_node_num):
                    item = conditional_random_pick(new_data_list[i],
                                                   [clique[i_clique]],
                                                   row_list[clique[j_clique]],
                                                   some_list, pro)
                    new_data_list[i][clique[j_clique]] = item[0]

            print('Drawn', clique[i_clique], clique[j_clique])

    return new_data_list