[][src]Function b2dp::utilities::discretesampling::conditional_lazy_threshold

pub fn conditional_lazy_threshold<R: ThreadRandGen>(
    eta: Eta,
    arithmeticconfig: &mut ArithmeticConfig,
    gamma_inv: &Float,
    threshold: &Float,
    cond_threshold: &Float,
    rng: R,
    optimize: bool
) -> Result<Float>

Determines whether the discretized Laplace exceeds the given threshold conditioned on it exceeding the given conditional threshold.

Arguments

Returns

Returns a Float with value Special::Infinity if greater than or equal to the threshold, otherwise returns with value Special::NegInfinity. Returns an error if eta cannot be appropriately adjusted or sum computation fails.

Exact Arithmetic

Does not explicitly enforce exact arithmetic, this is the caller's responsibility.

Privacy Budget

Uses eta privacy budget. Note that if multiple calls of conditional threshold are made in a chain, i.e., cond_threshold(T_0,T_1); cond_threshold(T_1,T_2) then the privacy budget may be shared among these calls. This accounting must be used with caution.

Timing Channels

Example Usage

// construct eta that can be adjusted for the desired value of gamma.
let eta = Eta::new(1,1,2)?; 
let mut arithmeticconfig = ArithmeticConfig::basic()?;
let rng = GeneratorOpenSSL {};
let gamma_inv = arithmeticconfig.get_float(2);
let cond_threshold = arithmeticconfig.get_float(0);
let threshold = arithmeticconfig.get_float(1);
arithmeticconfig.enter_exact_scope()?; 
let s = conditional_lazy_threshold(eta, & mut arithmeticconfig, 
                                    &gamma_inv, &threshold, 
                                    &cond_threshold, rng, false)?;
assert!(!s.is_finite()); // returns plus or minus infinity
if s.is_sign_positive() { /* Greater than the threshold */ ;}
else { /* Less than the threshold. */ ;}
let b = arithmeticconfig.exit_exact_scope();
assert!(b.is_ok()); // Must check that no inexact arithmetic was performed.