You are viewing an older version (2.4.3). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / random / RandomState / permutation

cython_function_or_method

numpy.random:RandomState.permutation

Signature

def   permutation ( x )

Summary

Randomly permute a sequence, or return a permuted range.

Extended Summary

If x is a multi-dimensional array, it is only shuffled along its first index.

Parameters

x : int or array_like

If x is an integer, randomly permute np.arange(x). If x is an array, make a copy and shuffle the elements randomly.

Returns

out : ndarray

Permuted sequence or array range.

Examples

np.random.permutation(10)
np.random.permutation([1, 4, 9, 12, 15])
arr = np.arange(9).reshape((3, 3))
np.random.permutation(arr)

See also

random.Generator.permutation

which should be used for new code.

Aliases

  • numpy.random.permutation
  • numpy.random.RandomState.permutation