Looseness in analytic Gaussian mechanism?
ryan112358 opened this issue · comments
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.
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.
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()
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?