コード例 #1
0
ファイル: exp1utility.py プロジェクト: pahfat/PoPETs2020
 def objective(phi00):
     phis = [phi00.item(k) for k in range(2 * d)]
     if any([x < 0 or x > 1 for x in phis + [sum(phis)]]):
         return 0  # used if finish != None in brute
     phim1 = 1 - sum(phis)
     pPhi = {k - d: phis[k] for k in range(2 * d)}
     pPhi[d] = phim1
     pPhis = [pPhi]
     pZsp = pZs + pPhis
     e = entropy.wme(g, pYs, pZsp, X)
     return -e
コード例 #2
0
    support = [f(*(X + Y + Z)) for Y in iproduct(*pYs) for Z in iproduct(*pZs)]
    j1 = merge_MPC.dmerge(support, d)

    def j(*x):
        return j1(f(*x))

    do = merge_MPC.do(f, pYs, pZs, X)
    k1 = merge_MPC.dyn_merge(do, d)

    def k(*x):
        return k1(f(*x))

    ## compute H(Y|O) and corresponding H(Y|O')'s

    xfs.append(iii)
    e1 = entropy.wme(f, pYs, pZs, X)
    yfs.append(e1)
    e2 = entropy.wme(g, pYs, pZs2, X)
    ygs.append(e2)
    e3 = entropy.wme(h, pYs, pZs, X)
    yhs.append(e3)

    e5 = entropy.wme(j, pYs, pZs, X)
    yjs.append(e5)
    e6 = entropy.wme(k, pYs, pZs, X)
    yks.append(e6)
    e7 = entropy.wme(g, pYs, pZs3, X)
    yls.append(e7)

    # compute optimal randomisation with independent noise
    optimal = True