nlcpy.random.Generator.shuffle

Generator.shuffle(self, x, axis=0)

Modifies a sequence in-place by shuffling its contents.

The order of sub-arrays is changed but their contents remains the same.

Parameters
xarray_like

The array or list to be shuffled.

axisint, optional

The axis which x is shuffled along. Default is 0. It is only supported on ndarray objects.

Returns
None

Examples

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