Function smartnoise_runtime::utilities::mechanisms::exponential_mechanism [−][src]
pub fn exponential_mechanism<T>(
epsilon: f64,
sensitivity: f64,
candidate_set: &[T],
utilities: Vec<f64>,
enforce_constant_time: bool
) -> Result<T> where
T: Clone,
Returns data element according to the Exponential mechanism.
Arguments
epsilon
- Multiplicative privacy loss parameter.sensitivity
- L1 sensitivity of utility function.candidate_set
- Data from which user wants an element returned.utility
- Utility function used within the exponential mechanism.enforce_constant_time
- Whether or not to enforce the algorithm to run in constant time
NOTE: This implementation is likely non-private because of the difference between theory on the real numbers and floating-point numbers. See Ilvento 2019 for more information on the problem and a proposed fix.
Example
use ndarray::prelude::*; use smartnoise_runtime::utilities::mechanisms::exponential_mechanism; // create utility function pub fn utility(x:&f64) -> f64 { let util = *x as f64; return util; } // create sample data let xs: Vec<f64> = vec![1., 2., 3., 4., 5.]; let utilities: Vec<f64> = xs.iter().map(utility).collect(); let ans = exponential_mechanism(1.0, 1.0, &xs, utilities, false);