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

  • Context: Mathematica 
  • Thread starter Thread starter natski
  • Start date Start date
  • Tags Tags
    Mathematica Table
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
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)
 
Brilliant, thank-you!