pub fn randint_device<'a, E: Into<Array>, T: ArrayElement>(
lower: E,
upper: E,
shape: impl IntoOption<&'a [i32]>,
key: impl Into<Option<&'a Array>>,
stream: impl AsRef<Stream>,
) -> Result<Array>
Expand description
Generate random integers from the given interval (lower:
and upper:
).
The values are sampled with equal probability from the integers in
half-open interval [lb, ub)
. The lower and upper bound can be
scalars or arrays and must be roadcastable to shape
.
use mlx_rs::{array, random};
let key = random::key(0).unwrap();
// generate an array of Int values, one in the range [0, 20) and one in the range [10, 100)
let array = random::randint::<_, i32>(array!([0, 20]), array!([10, 100]), None, &key);