def smooth_sensitivity_study(prior, sample_size, epsilon, delta, percentage): Bayesian_Model = BayesInferwithDirPrior(prior, sample_size, epsilon, delta) observation = [sample_size * i for i in percentage] Bayesian_Model._set_observation([sample_size * i for i in percentage]) Bayesian_Model._set_candidate_scores() Bayesian_Model._set_LS_Candidates() xstick = [ str((r._minus(Bayesian_Model._prior))._alphas) for r in Bayesian_Model._candidates ] beta = 0.00000001 y = [ Bayesian_Model._LS_Candidates[r] * math.exp(-beta * Hamming_Distance(observation, r._alphas)) for r in Bayesian_Model._candidates ] scatter_plot( y, xstick, 'Smooth Sensitivity Study w.r.t. x :' + str([sample_size * i for i in percentage]) + r'; $\epsilon = $' + str(epsilon) + r'; $\delta:$' + str(delta), r"$\Delta_l(H(BI(x'),-))e^{- \gamma *d(x,x')}$")
def smooth_sensitivity_study2(prior, sample_size, epsilon, delta, percentage): Bayesian_Model = BayesInferwithDirPrior(prior, sample_size, epsilon, delta) observation = [sample_size * i for i in percentage] Bayesian_Model._set_observation([sample_size * i for i in percentage]) Bayesian_Model._set_candidate_scores() Bayesian_Model._set_LS_Candidates() x = [(c._minus(Bayesian_Model._prior)) for c in Bayesian_Model._candidates] beta = 0.001 # math.log(1 - epsilon / (2.0 * math.log(delta / (2.0 * (sample_size))))) max_value_list = [] xstick = [ str((r._minus(Bayesian_Model._prior))._alphas) for r in Bayesian_Model._candidates ] for t in x: Bayesian_Model._set_observation(t._alphas) # Bayesian_Model._set_candidate_scores() # Bayesian_Model._set_LS_Candidates() max_value = 0.0 max_y = '' # max_y_list = [] for r in Bayesian_Model._candidates: temp = Bayesian_Model._LS_Candidates[r] * math.exp( -beta * Hamming_Distance(t._alphas, r._alphas)) if max_value < temp: max_y = r._alphas max_value = temp # for r in Bayesian_Model._candidates: # temp = Bayesian_Model._LS_Candidates[r] * math.exp(- beta * Hamming_Distance(observation, r._alphas)) # if max_value == temp: # max_y_list.append(str(r._alphas)) max_value_list.append(max_value) print "when data set x = " + str( t._alphas) + ", smooth sensitivity: S(" + str( t._alphas) + ") = " + str(max_value) scatter_plot( y, xstick, 'Smooth Sensitivity Given Size' + str(sample_size), )
def ss_ls_component_study(prior, sample_size, epsilon, delta, percentage): Bayesian_Model = BayesInferwithDirPrior(prior, sample_size, epsilon, delta) observation = [sample_size * i for i in percentage] Bayesian_Model._set_observation([sample_size * i for i in percentage]) Bayesian_Model._set_candidate_scores() Bayesian_Model._set_LS_Candidates() xstick = [str(c._alphas) for c in Bayesian_Model._candidates] beta = math.log(1 - epsilon / (2.0 * math.log(delta / (2.0 * (sample_size))))) y = [ 1.0 / ((1 - Bayesian_Model._LS_Candidates[r]**2)) for r in Bayesian_Model._candidates ] print abs(y[2] - y[1]) scatter_plot(y, xstick, "", r"$\frac{1}{LS((\alpha, 100 - \alpha))}$") return