Skip to contents

Generates random integers uniformly distributed over the interval [low, high).

Usage

mlx_rand_randint(
  dim,
  low,
  high,
  dtype = c("int32", "int64", "uint32", "uint64"),
  device = mlx_default_device()
)

Arguments

dim

Integer vector specifying the array shape/dimensions.

low

Lower bound (inclusive).

high

Upper bound (exclusive).

dtype

Desired integer dtype ("int32", "int64", "uint32", "uint64").

device

Execution target: provide "gpu", "cpu", or an mlx_stream created via mlx_new_stream(). Defaults to the current mlx_default_device().

Value

An mlx array of random integers.

Examples

# Random integers from 0 to 9
samples <- mlx_rand_randint(c(3, 3), low = 0, high = 10)

# Random integers from -5 to 4
samples <- mlx_rand_randint(c(2, 5), low = -5, high = 5)