Analysis of np.random.permutation()

np.random.permutation(): Randomly arrange the sequence.

Example 1: Randomly sort the sequence between 0-5

Insert picture description here

Example 2: Randomly sort a list

Insert picture description here

What's going on in multiple dimensions?

Insert picture description here

a matrix output is:

Insert picture description here

Now look at the c matrix, I ran it twice:
the first run result:

Insert picture description here

Then, I ran it again:

Insert picture description here

Through this example, it can be seen that for a multi-dimensional input, only random sorting is performed on the first dimension.
For this 3×3 matrix, just sort the rows randomly.

Guess you like

Origin blog.csdn.net/devil_son1234/article/details/108727087