Trait opendp::samplers::SampleGeometric[][src]

pub trait SampleGeometric: Sized {
    fn sample_geometric(
        shift: Self,
        positive: bool,
        prob: f64,
        trials: Option<Self>
    ) -> Fallible<Self>; }

Required methods

Sample from the censored geometric distribution with parameter prob. If trials is None, there are no timing protections, and the support is: [Self::MIN, Self::MAX] If trials is Some, execution runs in constant time, and the support is [Self::MIN, Self::MAX] ∩ {shift ±= {1, 2, 3, …, trials}}

Tail probabilities of the uncensored geometric accumulate at the extreme value of the support.

Arguments

  • shift - Parameter to shift the output by
  • positive - If true, positive noise is added, else negative
  • prob - Parameter for the geometric distribution, the probability of success on any given trial.
  • trials - If Some, run the algorithm in constant time with exactly this many trials.

Return

A draw from the censored geometric distribution defined above.

Example

use opendp::samplers::SampleGeometric;
let geom = u8::sample_geometric(0, true, 0.1, Some(20));

Implementors