Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looseness in analytic Gaussian mechanism? #39

Open
ryan112358 opened this issue Feb 15, 2023 · 3 comments
Open

Looseness in analytic Gaussian mechanism? #39

ryan112358 opened this issue Feb 15, 2023 · 3 comments

Comments

@ryan112358
Copy link

ryan112358 commented Feb 15, 2023

Here's a minimal example to demonstrate the issue:

from autodp import privacy_calibrator, dp_bank
import numpy as np

sigma = privacy_calibrator.ana_gaussian_mech(1.0, 1e-6)['sigma']
delta = np.exp(dp_bank.get_logdelta_ana_gaussian(1.0, sigma))

1.901276833828726e-05

I expect the delta = 1e-6, but it is nearly 20X larger according to DP bank.

@yuxiangw
Copy link
Owner

Thanks for the issue, Ryan!

'dp_bank.get_logdelta_ana_gaussian' has two arguments. the first should be sigma. the second should be the desired epsilon. In your implementation, it seems that you passed eps first, then delta?

by the way, autodp.privacy_calibrator has been deprecated. I am attaching the suggested implementation using a Calibrator class.

image

@ryan112358
Copy link
Author

Thanks for the quick response @yuxiangw, makes sense now! I'm still seeing some discrepancies for large epsilon, however:

def predicted_delta(epsilon, target_delta = 1e-6):
  try:
    calibrate = calibrator_zoo.ana_gaussian_calibrator()
    GM = calibrate(mechanism_zoo.GaussianMechanism, epsilon, target_delta)
    sigma = GM.params['sigma']
    return np.exp(dp_bank.get_logdelta_ana_gaussian(sigma, epsilon))
  except:
    return np.nan

epsilons = np.logspace(-10, 10, base=2, num=21)
predicted_deltas = [predicted_delta(eps) for eps in epsilons]
plt.plot([1/1024, 1024], [1e-6, 1e-6], 'k--', label='Target Delta')
plt.plot(epsilons, predicted_deltas, 'o', label='Actual Delta')
plt.xscale('log')
plt.xlabel('Epsilon')
plt.ylabel('Delta')
plt.legend()

download

@yuxiangw
Copy link
Owner

hmmmm... sorry it took me a long while to get back to you on this. I don't yet know the root cause of this, but it might be due the stopping condition for the numerical computation. Yuqing or I will try to look into this, but before that... did you manage to figure out the issue? Do you want to contribute a fix to make it more stable for large epsilons?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants