def Comparing_empirical_and_analytical_variance_b(): varslist = [] # return a list of (a list of variances) # Analytical BLH vars = analytical_eps_BLH(LocalHashing, 4, N) varslist.append(vars) # Empirical BLH vars = empirical_eps_BLH(LocalHashing, 4, N) varslist.append(vars) # Analytical OLH vars = analytical_eps_OLH(LocalHashing, 4, N) varslist.append(vars) # Empirical OLH vars = empirical_eps_OLH(LocalHashing, 4, N) varslist.append(vars) # Draw d = [item for item in range(2, (NUMBEROFAXIS + 1) * 2, 2) ] # 2^2, 2^4, ..., 2^18 draw.lines( d, varslist, ['Analytical BLH', 'Empirical BLH', 'Analytical OLH', 'Empirical OLH'], title='Comparing empirical and analytical variance', xlabel='Vary d(log2(x))', ylabel='Var(log10(y))')
def Comparing_empirical_and_analytical_variance_d(): varslist = [] # return a list of (a list of variances) # Analytical BLH vars = analytical_BLH(LocalHashing, 2**10, N) varslist.append(vars) # Empirical BLH vars = empirical_BLH(LocalHashing, 2**10, N) varslist.append(vars) # Analytical OLH vars = analytical_OLH(LocalHashing, 2**10, N) varslist.append(vars) # Empirical OLH vars = empirical_OLH(LocalHashing, 2**10, N) varslist.append(vars) # Draw epss = [0.5 + 0.5 * item for item in range(NUMBEROFAXIS)] # 0.5, 1.0, ..., 5.0 draw.lines( epss, varslist, ['Analytical BLH', 'Empirical BLH', 'Analytical OLH', 'Empirical OLH'], title='Comparing empirical and analytical variance', xlabel='Vary epsilon(log2(x))', ylabel='Var(log10(y))')
def numerical_values_of_var2(): varslist = [] # return a list of (a list of variances) d = 2**10 # 2^10 vars = analytical(SUE, d, 10000) for i in range(len(vars)): vars[i] = math.log(vars[i]) / math.log(10) varslist.append(vars) epss = [0.5 + 0.5 * item for item in range(10)] # 0.5, 1.0, ..., 5.0 draw.lines(epss, varslist, ['SUE'], ylabel='Var(log10(y))')
def numerical_values_of_var1(): varslist = [] # return a list of (a list of variances) for d in [2, 4, 16, 128, 2048]: vars = analytical(DE, d, 10000) for i in range(len(vars)): vars[i] = math.log(vars[i]) / math.log(10) varslist.append(vars) epss = [0.5+0.5*item for item in range(10)] # 0.5, 1.0, ..., 5.0 draw.lines(epss, varslist, ['DE(d=2)', 'DE(d=4)', 'DE(d=16)', 'DE(d=128)', 'DE(d=2048)'], ylabel='Var(log10(y))')
def numerical_values_of_var_a(): varslist = [] # return a list of (a list of variances) for d in [2, 4, 16, 128, 2048]: vars = analytical_DE(DirectEncoding, d, 10000) varslist.append(vars) # plot epss = [0.5 + 0.5 * item for item in range(10)] # 0.5, 1.0, ..., 5.0 draw.lines(epss, varslist, ['DE(d=2)', 'DE(d=4)', 'DE(d=16)', 'DE(d=128)', 'DE(d=2048)'], ylabel='Var(log10(y))')
def Comparing_empirical_and_analytical_variance1(): varslist = [] # return a list of (a list of variances) # Analytical DE vars = analytical_eps(DE, 4, 10000) for i in range(len(vars)): #log10 vars[i] = math.log(vars[i]) / math.log(10) varslist.append(vars) # Empirical DE vars = empirical_eps(DE, 4, 10000) # Draw d = [item for item in range(2, 20, 2)] # 2^2, 2^4, ..., 2^18 draw.lines(d, varslist, ['Analytical DE'], xlabel='Vary epislon(log2(x))', ylabel='Var(log10(y))')
def numerical_values_of_var_b(): varslist = [] # return a list of (a list of variances) d = 2**10 # 2^10 # DE vars = analytical_DE(DirectEncoding, d, 10000) varslist.append(vars) # BLH vars = analytical_BLH(LocalHashing, d, 10000) varslist.append(vars) # OLH vars = analytical_OLH(LocalHashing, d, 10000) # g = math.exp(epsilon)+1 varslist.append(vars) # plot epss = [0.5 + 0.5 * item for item in range(10)] # 0.5, 1.0, ..., 5.0 draw.lines(epss, varslist, ['DE', 'BLH', 'OLH'], ylabel='Var(log10(y))')
def drawFigure3(): numbers = readIntList('./data/kosarak.dat') numbers = numbers[0:10000] ###### too much values, so cut off maxnum = max(numbers) totnum = len(numbers) print('maxnum, totnum: ', maxnum, totnum) varslist = [] # Empirical BLH vars = empirical_BLH(LocalHashing, d=maxnum+1, numbers=numbers) varslist.append(vars) # Empirical OLH vars = empirical_OLH(LocalHashing, d=maxnum+1, numbers=numbers) varslist.append(vars) # Draw epss = [0.5+0.5*item for item in range(NUMBEROFAXIS)] # 0.5, 1.0, ..., 5.0 with open('temp_drawFigure3.py', 'w') as f: f.write(str(varslist)) draw.lines(epss, varslist, ['Empirical BLH', 'Empirical OLH'], title='Figure 3: Average squared error, varying epsilon', xlabel='Vary epsilon(x=epislon)', ylabel='y=log10(Var)')