Hi ,
How do I generate a new list randomly for the list m and then with the same random rule for the list n?
m={2,1,0,4,8} n={13,11,18,27,40}
This is equivalent to Rohit's proposal:
m = {2, 1, 0, 4, 8}; n = {13, 11, 18, 27, 40}; perm = Ordering[RandomReal[1, Length[m]]]; m = m[[perm]]; n = n[[perm]];
Hi Alex,
Here is another way.
permutation = RandomPermutation[Length@m]; Permute[m, permutation] Permute[n, permutation]
Hi Rohit,
Very neat solution.Thank you :)
What about this?
<< Combinatorica` m = {2, 1, 0, 4, 8} n = {13, 11, 18, 27, 40} nL = Length[m]; index = Nest[NextPermutation, Range[nL], RandomInteger[nL!]] mnew = Table[m[[index[[i]]]], {i, nL}] nnew = Table[n[[index[[i]]]], {i, nL}]
Thank you, Hans.
It was a great help:)