NumPy Tutorial · NumPy Random
Random Permutation
Learn all about Random Permutation in this comprehensive tutorial.
5 min read advanced
- •A permutation refers to an arrangement of elements.
- •Shuffle means changing arrangement of elements in-place.
Random Permutations of Elements
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().
Shuffling Arrays
Shuffle means changing arrangement of elements in-place. i.e. in the array itself.
python
Note: The shuffle() method makes changes to the original array.
Generating Permutation of Arrays
python
Note: The permutation() method returns a re-arranged array (and leaves the original array un-changed).
Module quiz
2 questions1
Which of the following is true about Random Permutation?
2
What is the most common pitfall when working with Random Permutation?
Answer all questions to submit.