nlcpy.random.RandomState.permutation

RandomState.permutation(self, x)

Randomly permutes a sequence, or returns a permuted range.

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

Parameters
xint or array_like

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

Returns
outndarray

Permuted sequence or array range.

Examples

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