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

Fix gaussian tau #298

Merged
merged 6 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.9.27] - 2024-12-11
### Fixed
- Fix gaussian tau.


## [0.9.26] - 2024-12-05
### Fixed
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Nicolas Grislain <ng@sarus.tech>"]
name = "qrlew"
version = "0.9.26"
version = "0.9.27"
edition = "2021"
description = "Sarus Qrlew Engine"
documentation = "https://docs.rs/qrlew"
Expand Down Expand Up @@ -34,7 +34,7 @@ r2d2_postgres = "0.18"
rust_decimal = { version = "1.35", features = [ "tokio-pg" ] }
statrs = "0.16.0"
sqlx = { version = "0.6.3", features = ["mssql", "runtime-tokio-native-tls", "offline", "any"], optional = true }
tokio = { version = "1", features = ["full"], optional = true }
tokio = { version = "1.37.0", features = ["full"], optional = true }

# bigquery dependencies
gcp-bigquery-client = { version = "=0.20.0", optional = true }
Expand Down
11 changes: 4 additions & 7 deletions src/differential_privacy/dp_event.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use itertools::Itertools;
use statrs::{
distribution::{ContinuousCDF, Normal},
prec::F64_PREC,
};
use statrs::distribution::{ContinuousCDF, Normal};
use std::fmt;

/// An object inspired by Google's [DPEvent](https://github.com/google/differential-privacy/blob/main/python/dp_accounting/dp_event.py)
Expand Down Expand Up @@ -169,9 +166,9 @@ pub fn gaussian_noise_multiplier(epsilon: f64, delta: f64) -> f64 {
((2. * (1.25_f64 / delta).ln()).sqrt() / epsilon).clamp(0.0, f64::MAX)
}

pub fn gaussian_tau(epsilon: f64, delta: f64, sensitivity: f64) -> f64 {
pub fn gaussian_tau(epsilon: f64, delta: f64, max_privacy_unit_groups: f64) -> f64 {
let dist = Normal::new(0.0, 1.0).unwrap();
let scale = gaussian_noise(epsilon, delta, sensitivity);
let scale = gaussian_noise(epsilon, delta, max_privacy_unit_groups.sqrt());
// TODO: we want to overestimate tau
1. + scale * dist.inverse_cdf((1. - delta / 2.).powf(1. / sensitivity)) + F64_PREC
1. + scale * dist.inverse_cdf((1. - delta).powf(1. / max_privacy_unit_groups))
}
2 changes: 1 addition & 1 deletion src/differential_privacy/dp_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl DpParameters {

pub fn from_epsilon_delta(epsilon: f64, delta: f64) -> DpParameters {
// These default values are underestimating the bounds
DpParameters::new(epsilon, delta, 0.5, 100.0, 0.1, 1)
DpParameters::new(epsilon, delta, 0.5, 100.0, 0.1, 5)
}

pub fn with_tau_thresholding_share(self, tau_thresholding_share: f64) -> DpParameters {
Expand Down
2 changes: 1 addition & 1 deletion src/differential_privacy/group_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl PupRelation {
// Apply noise
let name_sigmas = vec![(
COUNT_DISTINCT_PID,
dp_event::gaussian_noise(epsilon, delta, max_privacy_unit_groups as f64),
dp_event::gaussian_noise(epsilon, delta, (max_privacy_unit_groups as f64).sqrt()),
)];
let rel = rel.add_gaussian_noise(&name_sigmas);

Expand Down
Loading