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

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);