Function smartnoise_runtime::utilities::noise::sample_simple_geometric_mechanism[][src]

pub fn sample_simple_geometric_mechanism(
    scale: f64,
    min: i64,
    max: i64,
    enforce_constant_time: bool
) -> Result<i64>

Sample noise according to geometric mechanism

This function uses coin flips to sample from the geometric distribution, rather than using the inverse probability transform. This is done to avoid finite precision attacks.

For this algorithm, the number of steps it takes to sample from the geometric is bounded above by (max - min).

Arguments

Return

noise according to the geometric mechanism

Example

use ndarray::prelude::*;
use smartnoise_runtime::utilities::noise::sample_simple_geometric_mechanism;
let geom_noise = sample_simple_geometric_mechanism(1., 0, 100, false);