Exemple #1
0
def RDP_pureDP(params, alpha):
    """
    This function generically converts pure DP to Renyi DP.
    It implements Lemma 1.4 of Bun et al.'s CDP paper.
    With an additional cap at eps.

    :param params: pure DP parameter
    :param alpha: The order of the Renyi Divergence
    :return:Evaluation of the RDP's epsilon
    """
    eps = params['eps']
    # assert(eps>=0)
    # if alpha < 1:
    #     # Pure DP needs to have identical support, thus - log(q(p>0)) = 0.
    #     return 0
    # else:
    #     return np.minimum(eps,alpha*eps*eps/2)

    assert (alpha >= 0)
    if alpha == 1:
        # Calculate this by l'Hospital rule
        return eps * (math.cosh(eps) - 1) / math.sinh(eps)
    elif np.isinf(alpha):
        return eps
    elif alpha > 1:
        # in the proof of Lemma 4 of Bun et al. (2016)
        s, mag = utils.stable_log_diff_exp(
            utils.stable_log_sinh(alpha * eps),
            utils.stable_log_sinh((alpha - 1) * eps))
        return (mag - utils.stable_log_sinh(eps)) / (alpha - 1)
    else:
        return min(alpha * eps * eps / 2,
                   eps * (math.cosh(eps) - 1) / math.sinh(eps))
Exemple #2
0
 def rdp(alpha):
     assert (alpha >= 0)
     if alpha == 1:
         # Calculate this by l'Hospital rule
         return eps * (math.cosh(eps) - 1) / math.sinh(eps)
     elif np.isinf(alpha):
         return eps
     elif alpha > 1:
         # in the proof of Lemma 4 of Bun et al. (2016)
         s, mag = utils.stable_log_diff_exp(
             utils.stable_log_sinh(alpha * eps),
             utils.stable_log_sinh((alpha - 1) * eps))
         return (mag - utils.stable_log_sinh(eps)) / (alpha - 1)
     else:
         return min(alpha * eps * eps / 2,
                    eps * (math.cosh(eps) - 1) / math.sinh(eps))