Function smartnoise_runtime::utilities::noise::sample_gaussian_truncated [−][src]
pub fn sample_gaussian_truncated(
min: f64,
max: f64,
shift: f64,
scale: f64,
enforce_constant_time: bool
) -> Result<f64>
Sample from truncated Gaussian distribution.
This function uses a rejection sampling approach. This means that values outside of the truncation bounds are ignored, rather than pushed to the bounds (as they would be for a censored distribution).
Arguments
shift
- The expectation of the untruncated Gaussian distribution.scale
- The scaling parameter (standard deviation) of the untruncated Gaussian distribution.min
- The minimum value you want to allow to be sampled.max
- The maximum value you want to allow to be sampled.
Return
A draw from a Gaussian(shift, scale) truncated to [min, max].
Example
use smartnoise_runtime::utilities::noise::sample_gaussian_truncated; let n= sample_gaussian_truncated(0.0, 1.0, 0.0, 2.0, false);