A permutation refers to an arrangement of elements. e.g. [3, 2, 1] is a permutation of [1, 2, 3] and vice-versa. The NumPy Random module provides two methods for this: shuffle() and permutation() .
That is, the permutation is a group element and the shuffle is the result of its action on a particular word. One can debate whether this is a good use of terminology (it seems reasonable to me), but that is the distinction being made. It reflects a quite formal mathematical point of view
Randomly permute a sequence, or return a permuted range. If x is a multi-dimensional array, it is only shuffled along its first index. Note.
from numpy import random
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(random.permutation(arr))
references:
https://www.w3schools.com/python/numpy/numpy_random_permutation.asp
No comments:
Post a Comment