def conditional_marginal2(condition_list, clique, bit_list, bit_cand_list, row_list, bitsum_list, f, dt): #################################################################################### # To generate conditional probability and acceptable items for sampling pro = [] some_list = [] rest_list = list(set(clique) - set(condition_list)) rest_list.sort() if len(condition_list) == 1: att_indexs1 = condition_list[0] att_rappor_list_combine1 = bit_list[att_indexs1] att_signal_list_combine1 = bit_cand_list[att_indexs1] att_row_list_combine1 = row_list[att_indexs1] else: att_indexs1 = condition_list att_rappor_list_combine1, att_signal_list_combine1, att_row_list_combine1 = att_combin( bit_list, bit_cand_list, row_list, att_indexs1) if len(rest_list) == 1: att_indexs2 = rest_list[0] att_rappor_list_combine2 = bit_list[att_indexs2] att_signal_list_combine2 = bit_cand_list[att_indexs2] att_row_list_combine2 = [row_list[att_indexs2]] else: att_indexs2 = rest_list att_rappor_list_combine2, att_signal_list_combine2, att_row_list_combine2 = att_combin( bit_list, bit_cand_list, row_list, att_indexs2) proe = estimate_2d2(att_signal_list_combine1, att_signal_list_combine2, bitsum_list, clique) #print(proe) protemp = proe #lenpro=len(protemp) leng1 = len(att_signal_list_combine1) leng2 = len(att_signal_list_combine2) ptemp = [[] for i in range(leng1)] for i in range(leng1): for j in range(leng2): ptemp[i].append(protemp[i][j]) condition_some_list = att_row_list_combine1 #some_list=att_row_list_combine2 some_list = row_list_product(row_list, rest_list) #print(condition_some_list) #print(some_list) #print('true:',true_joint_distribution(bit_list,row_list,clique)) #print('estimate:',ptemp) return condition_some_list, some_list, ptemp
def independent_marginal2(clique, bit_list, bit_cand_list, row_list, bitsum_list, f, dt): ################################################################## # To generate independent probability and possible list for sampling #print(row_list) leng = len(clique) #print(leng) pro = [] some_list = [] if leng == 1: att_index1 = clique[0] ptemp = Get_Rappor.lasso_regression([bit_cand_list[att_index1]], [bitsum_list[att_index1]]) pro = ptemp[0] some_list = row_list[clique[0]] if leng == 2: att_index1 = clique[0] att_index2 = clique[leng - 1] ptemp = estimate_2d2(bit_cand_list[att_index1], bit_cand_list[att_index2], bitsum_list, clique) #Get_Rappor.lasso_regression([bit_cand_list[att_index1]], [bitsum_list[att_index1]]) proe = ptemp proleng = len(proe) for i in range(proleng): pro.extend(proe[i]) #print('lasso estimate:',pro) #some_list=list_product([row_list[clique[0]]],[row_list[clique[1]]]) some_list = row_product(row_list[clique[0]], row_list[clique[1]]) if leng > 2: 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) #print(att_row_list_combine) proe = estimate_2d2(bit_cand_list[att_index1], att_signal_list_combine, bitsum_list, clique) #print(proe) #pro=proe[0] #proe=estimate_2d(bit_list[att_index1],att_rappor_list_combine,bit_cand_list[att_index1],att_signal_list_combine,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) some_list = row_product(row_list[clique[0]], att_row_list_combine) #print('lasso estimate:',pro) some_list = row_list_product(row_list, clique) #print(some_list) #print(pro) return some_list, pro
def conditional_marginal(condition_list, clique, bit_list, bit_cand_list, row_list, bitsum_list, f, dt): #################################################################################### # To generate conditional probability and acceptable items for sampling pro = [] some_list = [] rest_list = list(set(clique) - set(condition_list)) rest_list.sort() if len(condition_list) == 1: att_indexs1 = condition_list[0] att_rappor_list_combine1 = bit_list[att_indexs1] att_signal_list_combine1 = bit_cand_list[att_indexs1] att_row_list_combine1 = row_list[att_indexs1] else: att_indexs1 = condition_list att_rappor_list_combine1, att_signal_list_combine1, att_row_list_combine1 = att_combin( bit_list, bit_cand_list, row_list, att_indexs1) if len(rest_list) == 1: att_indexs2 = rest_list[0] att_rappor_list_combine2 = bit_list[att_indexs2] att_signal_list_combine2 = bit_cand_list[att_indexs2] att_row_list_combine2 = row_list[att_indexs2] else: att_indexs2 = rest_list att_rappor_list_combine2, att_signal_list_combine2, att_row_list_combine2 = att_combin( bit_list, bit_cand_list, row_list, att_indexs2) pro = estimate_2d(att_rappor_list_combine1, att_rappor_list_combine2, att_signal_list_combine1, att_signal_list_combine2, bitsum_list, clique, f, dt) condition_some_list = att_row_list_combine1 some_list = att_row_list_combine2 #print(condition_some_list) #print(some_list) #print('true:',true_joint_distribution(bit_list,row_list,clique)) #print('estimate:',pro) return condition_some_list, some_list, pro
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
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