예제 #1
0
    def __init__(self, p=None, name='Randresponse'):
        Mechanism.__init__(self)

        self.name = name
        self.params = {'p': p}  # This will be useful for the Calibrator
        self.delta0 = 0
        if p is not None:
            new_rdp = lambda x: rdp_bank.RDP_randresponse({'p': p}, x)
            self.propagate_updates(new_rdp, 'RDP')
예제 #2
0
    def __init__(self, p=None, RDP_off=False, phi_off=True, name='Randresponse'):
        """
        p: the Bernoulli probability p of outputting the truth.
        """
        Mechanism.__init__(self)

        self.name = name
        self.params = {'p': p}
        self.delta0 = 0

        if not RDP_off:
            new_rdp = lambda x: rdp_bank.RDP_randresponse({'p': p}, x)
            self.propagate_updates(new_rdp, 'RDP')
            approxDP = lambda x: dp_bank.get_eps_randresp_optimal(p, x)
            self.propagate_updates(approxDP, 'approxDP_func')

        if not phi_off:
            log_phi = lambda x: phi_bank.phi_rr_p({'p': p, 'q':1-p}, x)
            self.log_phi_p = self.log_phi_q = log_phi
            self.propagate_updates((self.log_phi_p, self.log_phi_q), 'log_phi')
예제 #3
0
def get_eps_randresp(p, delta):
    assert (delta >= 0)
    func = lambda x: rdp_bank.RDP_randresponse({'p': p}, x)
    return get_eps_rdp(func, delta)
예제 #4
0
파일: eps.py 프로젝트: jeremy43/autodp-1

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):