pub trait SampleGeometric<P>: Sized {
    // Required method
    fn sample_geometric(
        shift: Self,
        positive: bool,
        prob: P,
        trials: Option<Self>
    ) -> Fallible<Self>;
}
Expand description

Sample from the censored geometric distribution.

Required Methods§

source

fn sample_geometric( shift: Self, positive: bool, prob: P, trials: Option<Self> ) -> Fallible<Self>

Proof Definition

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 ± {0, 1, 2, ..., 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::traits::samplers::SampleGeometric;
let geom = u8::sample_geometric(0, true, 0.1, Some(20));

Implementors§