Skip to content
Prev 276666 / 398506 Next

rearrange set of items randomly

On 08-Nov-11 08:59:38, Ted Harding wrote:
While I am at it, an alternative to this use of sample()
is to use order() to find the permutation which re-arranges
a set of random numbers into increasing order. This in effect
returns a random permutation of (1:N). Hence, instead of
"ix <- sample(1:N))" in the above, you could use:

  ix <- order(runif(N))

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 08-Nov-11                                       Time: 09:30:33
------------------------------ XFMail ------------------------------