示例#1
0
def empirical_eps_DE(protocol, epsilon, n):
    vars = []
    for step in range(NUMBEROFAXIS):  # 9 values
        d = 2**(2 + step * 2)
        x = protocol(d, epsilon)  # init
        users = zipf.zipf(1.1, d, n)
        for i in range(len(users)):
            x.PE(users[i])
        x.aggregation()  # estimate couterEsti

        f = zipf.probList(1.1, d, n)
        var = x.var_empirical(f, n)
        vars.append(math.log10(var))  # log10(var)
    return vars
示例#2
0
def empirical_eps_BLH(protocol, epsilon, n):
    vars = []
    for step in range(NUMBEROFAXIS):
        d = 2**(2 + step * 2)
        x = protocol(d, epsilon, g=2)  # init
        users = zipf.zipf(1.1, d, n)
        for i in range(len(users)):
            if i % 1000 == 0:
                print(step, i, 'BLH')
            x.PE(users[i])
        x.aggregation()  # estimate couterEsti

        f = zipf.probList(1.1, d, n)
        var = x.var_empirical(f, n)
        vars.append(math.log10(var))
    return vars
示例#3
0
def empirical_eps_OLH(protocol, epsilon, n):
    vars = []
    g = 53  # round(math.exp(epsilon)+1)效果不好,要取最近的素数(因为universal hashing!!)
    for step in range(NUMBEROFAXIS):  #### 9 values
        d = 2**(2 + step * 2)
        x = protocol(d, epsilon, g)  # init
        users = zipf.zipf(1.1, d, n)
        for i in range(len(users)):
            if i % 1000 == 0:
                print(step, i, 'OLH')
            x.PE(users[i])
        x.aggregation()  # estimate couterEsti

        f = zipf.probList(1.1, d, n)
        var = x.var_empirical(f, n)
        vars.append(math.log10(var))
    return vars
示例#4
0
def empirical_OLH(protocol, d, n):
    vars = []
    primeList = [3, 3, 5, 7, 13, 23, 37, 53, 89,
                 149]  # according to epsilon=[0.5, 1.0, ..., 5.0]
    for step in range(NUMBEROFAXIS):  # 10 values
        epsilon = 0.5 + 0.5 * step
        x = protocol(
            d, epsilon, g=primeList[step]
        )  # round(math.exp(epsilon)+1)效果不好,要取最近的素数(因为universal hashing!!)
        users = zipf.zipf(1.1, d, n)
        for i in range(len(users)):
            if i % 1000 == 0:
                print(step, i, "OLH")
            x.PE(users[i])
        x.aggregation()  # estimate couterEsti

        f = zipf.probList(1.1, d, n)
        var = x.var_empirical(f, n)
        vars.append(math.log10(var))
    return vars
示例#5
0
def empirical_eps(protocol, epsilon, n):
    vars = []
    for step in range(7):  # 9 values
        d = 2**(2 + step * 2)
        #f = []
        x = protocol(d, epsilon, n)
        users = zipf.zipf(1.1, d, n)
        for i in range(n):  # random PE
            if i % 1000 == 0:
                print(i, step)
            #m = random.randint(1,d)
            #x.PE(m)
            x.PE(users[i] + 1)

        f = zipf.probList(1.1, d, n)
        #for i in range(d):
        #    f.append(1.0/d)
        #print(f)
        x.aggregation()
        vars.append(x.var_empirical(f))
    return vars