# mlx.core.random.randint — MLX 0.0.7 documentation

Skip to main content
`Ctrl`+`K`

# mlx.core.random.randint

mlx.core.random.randint(low: Union[ bool , int , float , complex , object ], high: Union[ bool , int , float , complex , object ], shape: List[ int ] = [], dtype: Optional[ Dtype ] = mlx.core.int32, key: Optional[ array ] = None, stream: Union[ None , Stream , Device ] = None) → array

  Generate random integers from the given interval.

  The values are sampled with equal probability from the integers in half-open interval `[low, high)`. The lower and upper bound can be scalars or arrays and must be roadcastable to `shape`.

  Parameters:

    - low (scalar or array) – Lower bound of the interval.

    - high (scalar or array) – Upper bound of the interval.

    - shape (list ( int ), optional) – Shape of the output. Defaults to `()`.

    - dtype (Dtype , optional) – Type of the output. Defaults to `int32`.

    - key (array , optional) – A PRNG key. Default: None.

  Returns:

    The array of random integers.

  Return type:

    array