This is a pre-release version (2.5.0.dev0+git20251130.2de293a). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / 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_like

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

axis : int, optional

The axis which x is shuffled along. Default is 0.

Returns

out : ndarray

Permuted 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

Referenced by