bundles / numpy 2.4.4 / numpy / random / _generator / Generator / permuted
cython_function_or_method
numpy.random._generator:Generator.permuted
Signature
def permuted ( x , axis = None , out = None ) Summary
Randomly permute x along axis axis.
Extended Summary
Unlike shuffle, each slice along the given axis is shuffled independently of the others.
Parameters
x: array_like, at least one-dimensionalArray to be shuffled.
axis: int, optionalSlices of
xin this axis are shuffled. Each slice is shuffled independently of the others. Ifaxisis None, the flattened array is shuffled.out: ndarray, optionalIf given, this is the destination of the shuffled array. If
outis None, a shuffled copy of the array is returned.
Returns
: ndarrayIf
outis None, a shuffled copy ofxis returned. Otherwise, the shuffled array is stored inout, andoutis returned
Notes
An important distinction between methods shuffle and permuted is how they both treat the axis parameter which can be found at generator-handling-axis-parameter.
Examples
Create a `numpy.random.Generator` instance:rng = np.random.default_rng()
✓x = np.arange(24).reshape(3, 8) x✓
y = rng.permuted(x, axis=1)
✓y
✗x
✓y = rng.permuted(x, axis=1, out=x)
✓x
✗y is x
✓See also
Aliases
-
numpy.random.Generator.permuted