statistics_noise.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:privcount 作者: privcount 项目源码 文件源码
def get_differentially_private_std(sensitivity, epsilon, delta,
                                   tol=DEFAULT_SIGMA_TOLERANCE):
    '''
    Determine smallest standard deviation for a normal distribution such that
    the probability of a value violating epsilon-differential privacy is at
    most delta.
    '''

    # std upper bound determined by improving result in literature,
    # Hardt and Roth, "Beating Randomized Response on Incoherent Matrices"
    # Thm. 2.6 (and the Lemma in App. A) can be improved to provide the
    # following upper bound
    std_upper_bound = (float(sensitivity)/epsilon) * (4.0/3.0) *\
        (2 *  math.log(1.0/delta))**(0.5)
    std_lower_bound = tol # use small but non-zero value for std lower-bound
    if (satisfies_dp(sensitivity, epsilon, delta, std_lower_bound) is True):
        raise ValueError('Could not find lower bound for std interval.')

    std = interval_boolean_binary_search(\
        lambda x: satisfies_dp(sensitivity, epsilon, delta, x), std_lower_bound,
        std_upper_bound, tol, return_true=True)

    return std
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号