def __init__(self, b=None, name='Laplace', RDP_off=False, phi_off=True): """ b: the ratio of the scale parameter and L1 sensitivity. RDP_off: if False, then we characterize the mechanism using RDP. fdp_off: if False, then we characterize the mechanism using fdp. phi_off: if False, then we characterize the mechanism using phi-function. """ Mechanism.__init__(self) self.name = name self.params = {'b': b} # This will be useful for the Calibrator self.delta0 = 0 if not phi_off: log_phi_p = lambda x: phi_bank.phi_laplace(self.params, x) log_phi_q = lambda x: phi_bank.phi_laplace(self.params, x) self.log_phi_p = log_phi_p self.log_phi_q = log_phi_q self.propagate_updates((log_phi_p, log_phi_q), 'log_phi') if not RDP_off: new_rdp = lambda x: rdp_bank.RDP_laplace({'b': b}, x) self.propagate_updates(new_rdp, 'RDP')
def __init__(self, b=None, name='Laplace'): Mechanism.__init__(self) self.name = name self.params = {'b': b} # This will be useful for the Calibrator self.delta0 = 0 if b is not None: new_rdp = lambda x: rdp_bank.RDP_laplace({'b': b}, x) self.propagate_updates(new_rdp, 'RDP')
def get_eps_laplace(b, delta): assert (delta >= 0) func = lambda x: rdp_bank.RDP_laplace({'b': b}, x) return get_eps_rdp(func, delta)
def get_moment(alpha, sigma, gamma): t = 3 part_1 = gamma**2*alpha/((1-gamma)*sigma**2) part_2 = (2*gamma)**t/((1-gamma)**t*sigma**(2*t)) part_3 = (2*gamma)**t*(t-1)/(2*(1-gamma)**(t-1)*sigma**t) part_4 = (2*prob)**t*np.exp((t**2-t)/(2*sigma**2))*(sigma**t*2+t**t)/(2*(1-gamma)**(t-1)*sigma**(2*t)) bound = part_1 + alpha*(alpha-2)/6*(part_2+part_3+part_4) part_sum = 4 * alpha * (alpha - 2) * gamma ** 3 / (3 * sigma ** 3) return bound # get the CGF functions func_gaussian = lambda x: rdp_bank.RDP_gaussian({'sigma': sigma}, x) func_laplace = lambda x: rdp_bank.RDP_laplace({'b': b}, x) func_randresp = lambda x: rdp_bank.RDP_randresponse({'p':p}, x) func_moment = lambda x: get_moment({'gamma':prob,'sigma':sigma},x) funcs = { 'gaussian':func_gaussian,'laplace': func_laplace, 'randresp': func_randresp} # A placeholder to save results for plotting purposes results_for_figures = {} # compute feasible alpha list for moment account in Abadi et. al.2016 moment =[] moment_alpha =np.linspace(1, alpha_limit, alpha_limit).astype(int) for mm in moment_alpha: moment.append(get_moment(mm, sigma, prob)) moment_cache = np.zeros(alpha_limit) moment = np.array(moment) def get_eps_moment(alpha,cache):