Trait opendp::samplers::SampleUniform[][src]

pub trait SampleUniform: Sized {
    fn sample_standard_uniform(constant_time: bool) -> Fallible<Self>;
}

Required methods

Returns a random sample from Uniform[0,1).

This algorithm is taken from Mironov (2012) and is important for making some of the guarantees in the paper.

The idea behind the uniform sampling is to first sample a “precision band”. Each band is a range of floating point numbers with the same level of arithmetic precision and is situated between powers of two. A band is sampled with probability relative to the unit of least precision using the Geometric distribution. That is, the uniform sampler will generate the band [1/2,1) with probability 1/2, [1/4,1/2) with probability 1/4, and so on.

Once the precision band has been selected, floating numbers numbers are generated uniformly within the band by generating a 52-bit mantissa uniformly at random.

Arguments

min: f64 minimum of uniform distribution (inclusive) max: f64 maximum of uniform distribution (non-inclusive)

Return

Random draw from Unif[min, max).

Example

// valid draw from Unif[0,1)
use opendp::samplers::SampleUniform;
let unif = f64::sample_standard_uniform(false);

Implementations on Foreign Types

Implementors