bundles / numpy 2.4.4 / numpy / random / _generator / Generator / permutation
cython_function_or_method
numpy.random._generator:Generator.permutation
Signature
def permutation ( x , axis = 0 ) Summary
Randomly permute a sequence, or return a permuted range.
Parameters
x: int or array_likeIf
xis an integer, randomly permutenp.arange(x). Ifxis an array, make a copy and shuffle the elements randomly.axis: int, optionalThe axis which
xis shuffled along. Default is 0.
Returns
out: ndarrayPermuted sequence or array range.
Examples
rng = np.random.default_rng()
✓rng.permutation(10)
✗rng.permutation([1, 4, 9, 12, 15])
✗arr = np.arange(9).reshape((3, 3))
✓rng.permutation(arr)
✗rng.permutation("abc")
✓arr = np.arange(9).reshape((3, 3))
✓rng.permutation(arr, axis=1)
✗Aliases
-
numpy.random.Generator.permutation