mlx.core.random.permutation

Contents

mlx.core.random.permutation#

permutation(x: int | array, axis: int = 0, key: array | None = None, stream: None | Stream | Device = None) array#

Generate a random permutation or permute the entries of an array.

Parameters:
  • x (int or array, optional) – If an integer is provided a random permtuation of mx.arange(x) is returned. Otherwise the entries of x along the given axis are randomly permuted.

  • axis (int, optional) – The axis to permute along. Default: 0.

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

Returns:

The generated random permutation or randomly permuted input array.

Return type:

array