pub struct SensitivityAnalyzer { /* private fields */ }Expand description
Sensitivity analyzer
Implementations§
Source§impl SensitivityAnalyzer
impl SensitivityAnalyzer
pub fn new() -> Self
pub fn initialize(&mut self) -> Result<(), StatisticalError>
Sourcepub fn register_function(&mut self, name: &str, func: SensitivityFunction)
pub fn register_function(&mut self, name: &str, func: SensitivityFunction)
Register a named sensitivity function so it can be looked up by name
from compute_sensitivity / get_sensitivity.
Sourcepub fn compute_sensitivity(
&mut self,
operation: &str,
data: &[f64],
) -> Result<f64, StatisticalError>
pub fn compute_sensitivity( &mut self, operation: &str, data: &[f64], ) -> Result<f64, StatisticalError>
Compute the L1 sensitivity of a statistical operation over data.
Sensitivity is the maximum change in the operation’s output when a single record is added or removed. The following closed-form approximations are used (each assumes a bounded domain where one record can shift a value by at most 1.0):
mean:1/n— one record moves the mean by1/n.sum:1.0— one record changes the sum by at most 1.count:1.0— one record changes the count by 1.median:range / n— adjacent-element approximation.variance:(max-min)^2 / n— bounded shift approximation.histogram:1.0— one record changes a single bin by 1.
Results are cached keyed by operation so repeated DP queries reuse the
computed sensitivity.
Sourcepub fn get_sensitivity(
&mut self,
operation: &str,
data: &[f64],
) -> Result<f64, StatisticalError>
pub fn get_sensitivity( &mut self, operation: &str, data: &[f64], ) -> Result<f64, StatisticalError>
Get the sensitivity for an operation, returning the cached value when available and computing (and caching) it otherwise.
Auto Trait Implementations§
impl Freeze for SensitivityAnalyzer
impl RefUnwindSafe for SensitivityAnalyzer
impl Send for SensitivityAnalyzer
impl Sync for SensitivityAnalyzer
impl Unpin for SensitivityAnalyzer
impl UnsafeUnpin for SensitivityAnalyzer
impl UnwindSafe for SensitivityAnalyzer
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Aggregate shares in an MPC protocol.
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
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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