pub struct RandomizedResponse { /* private fields */ }not differentially private (predictable xorshift64 noise, clock seed, floating-point inverse transform); use privacy::{dp_int, dp_sum, DpNoise, randomized_response, KeyedRappor}
Expand description
Randomized Response for binary data
Classic technique: to report a sensitive bit b:
- With probability p, report b truthfully
- With probability 1-p, report a random bit
This provides ε-differential privacy where ε = ln((p + 0.5(1-p)) / (0.5(1-p)))
Implementations§
Source§impl RandomizedResponse
impl RandomizedResponse
Sourcepub fn new(epsilon: f64) -> Self
pub fn new(epsilon: f64) -> Self
Create from privacy parameter epsilon
Higher epsilon = more accuracy, less privacy
Sourcepub fn with_probability(p_true: f64, seed: u64) -> Self
pub fn with_probability(p_true: f64, seed: u64) -> Self
Create with explicit probability and seed
Sourcepub fn privatize_bit(&mut self, bit: u8) -> u8
pub fn privatize_bit(&mut self, bit: u8) -> u8
Privatize a bit (0 or 1)
Sourcepub fn estimate_proportion(p_true: f64, n: u64, k: u64) -> f64
pub fn estimate_proportion(p_true: f64, n: u64, k: u64) -> f64
Estimate true proportion from noisy counts
Given N total responses with K positive responses, estimate the true proportion of positive values.
§Panics
Panics unless 0 < p_true ≤ 1: with p_true = 0 every report is a coin
flip and carries no information (the estimate was NaN).
Trait Implementations§
Source§impl Clone for RandomizedResponse
impl Clone for RandomizedResponse
Auto Trait Implementations§
impl Freeze for RandomizedResponse
impl RefUnwindSafe for RandomizedResponse
impl Send for RandomizedResponse
impl Sync for RandomizedResponse
impl Unpin for RandomizedResponse
impl UnsafeUnpin for RandomizedResponse
impl UnwindSafe for RandomizedResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more