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

  • Topic: Mathematica 
  • Thread starter Thread starter natski
  • Start date Start date
  • Tags Tags
    Mathematica Table
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
2 replies · 3K views
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)