google / differential-privacy

Google's differential privacy libraries.
Apache License 2.0
3.07k stars 346 forks source link

Golang: fix confidence interval calculations with the correct confidence level #99

Closed osuketh closed 2 years ago

osuketh commented 2 years ago

Fixed confidence interval for the numerator because it was calculated using the confidence level for the denominator in Golang's mean implementation. The same was true for the confidence interval for the denominator.

This corresponds to the Java code here.

miracvbasaran commented 2 years ago

Hey @osuketh,

Thanks for the PR, good catch!

It seems that using alphaNum for the denominator and alphaDen for the numerator doesn't change the output significantly since in both versions (this PR and the one currently in the repository) we try 1000 different value pairs for alphaNum and alphaDen and pick the best one. The outputs are only very slightly different (perhaps by a margin<1e-4 for lower & upper bounds) because the set of the value pairs are somewhat different. Both versions would give a "correct" confidence interval I guess, that's why the tests didn't fail, but using alphaNum for the numerator and alphaDen for the denominator as intended is obviously a good idea.