Mathematica How can I randomly shuffle the positions within a Mathematica table?

  • Thread starter Thread starter natski
  • Start date Start date
  • Tags Tags
    Mathematica Table
AI Thread Summary
To randomly shuffle the positions within a Mathematica table, the RandomPermutation[] function can be used effectively. This function allows for a straightforward way to rearrange elements in a table randomly. Users need to ensure that the DiscreteMath package is loaded to access this function. The discussion highlights the simplicity of this solution, with one user expressing gratitude for the guidance. Utilizing RandomPermutation[] is the recommended approach for achieving random shuffling in Mathematica.
natski
Messages
262
Reaction score
2
Hi everyone,

Does anybody know how to randomly shuffle the positions within a table about? For example a table T = {1,2,3,4,5,6...} gets randomly shuffled to be T' = {7,3,5,1,4...} [or whatever].

I thought there might be some kind of intrinsic RandomShuffle kind of function but can't find one...

Natski
 
Physics news on Phys.org
Use the RandomPermutation[] function. It should do the trick. (need to load the DiscreteMath package to use it)
 
Brilliant, thank-you!
 

Similar threads

Replies
2
Views
2K
Replies
2
Views
2K
Replies
3
Views
3K
Replies
5
Views
3K
Replies
6
Views
3K
Replies
1
Views
3K
Replies
2
Views
5K
Back
Top