Function smartnoise_runtime::utilities::noise::sample_uniform_int [−][src]
pub fn sample_uniform_int(min: Integer, max: Integer) -> Result<Integer>
Sample from uniform integers between min and max (inclusive).
Arguments
min
- &i64, minimum value of distribution to sample frommax
- &i64, maximum value of distribution to sample from
Return
Random uniform variable between min and max (inclusive).
Example
// returns a uniform draw from the set {0,1,2} use smartnoise_runtime::utilities::noise::sample_uniform_int; let n = sample_uniform_int(0, 2).unwrap(); assert!(n == 0 || n == 1 || n == 2);
ⓘ
// fails because min > max use smartnoise_runtime::utilities::noise::sample_uniform_int; let n = sample_uniform_int(2, 0);