Function opendp::traits::samplers::discretize::sample_discrete_gaussian_Z2k
source · pub fn sample_discrete_gaussian_Z2k<T>(
shift: T,
scale: T,
k: i32
) -> Fallible<T>where
T: CastInternalRational,
Expand description
Sample from the discrete gaussian distribution on $\mathbb{Z} \cdot 2^k$.
Implemented for floating-point types f32 and f64.
k can be chosen to be very negative, to get an arbitrarily fine approximation to continuous gaussian noise.
§Proof Definition
For any setting of the input arguments, return either
Err(e)
if there is insufficient system entropy, or
Ok(sample)
, where sample
is distributed according to a modified discrete_gaussian(shift
, scale
).
The modifications to the discrete gaussian are as follows:
- the
shift
is rounded to the nearest multiple of $2^k$ - the
sample
is rounded to the nearest value of typeT
. - the noise granularity is in increments of $2^k$.