flopscope.

flopscope.numpy.random.RandomState.permutation

fnp.random.RandomState.permutation(self, x)

Randomly permute a sequence, or return a permuted range.

Adapted from NumPy docs np.random.RandomState.permutation

Arearandom
Typecounted
Cost
shape[axis]\text{shape}[\text{axis}]
Flopscope Context

Legacy permutation; cost = shape[axis] (Fisher-Yates draws). RandomState has no axis kwarg; defaults to 0.

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

Note.

New code should use the permutation method of a Generator instance instead; please see the random-quick-start.

Parameters

x:int or array_like

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

Returns

out:ndarray

Permuted sequence or array range.

See also

Examples

>>> flops.random.permutation(10)
array([1, 7, 4, 3, 0, 9, 2, 5, 8, 6]) # random
>>> flops.random.permutation([1, 4, 9, 12, 15])
array([15,  1,  9,  4, 12]) # random
>>> arr = flops.arange(9).reshape((3, 3))
>>> flops.random.permutation(arr)
array([[6, 7, 8], # random
       [0, 1, 2],
       [3, 4, 5]])