bundles / numpy 2.5.0.dev0+git20251130.2de293a / 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_likeIf
xis an integer, randomly permutenp.arange(x). Ifxis an array, make a copy and shuffle the elements randomly.
Returns
out: ndarrayPermuted 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