Hi,
I was wondering the what would be the (most efficient) way to generate
a sequence
of sequences, i mean:
if I have 1,2 and 3.
I'd like to generate a sequence of length N*3 (N ~ 1,000,000 or more)
Where random permutations of the sequence 1,2,3 follow each other.
i.e 1,2,3,1,3,2,3,2,1
/!\
One way:
N - 10
s - c(apply(matrix(rep(1:3,N),3,N),2,sample))
url:www.econ.uiuc.edu/~rogerRoger Koenker
email[EMAIL PROTECTED]Department of Economics
vox: 217-333-4558University of Illinois
fax: 217-244-6678
On 22/08/2007, at 8:49 AM, Emmanuel Levy wrote:
Hi,
I was wondering the what would be the (most efficient) way to generate
a sequence
of sequences, i mean:
if I have 1,2 and 3.
I'd like to generate a sequence of length N*3 (N ~ 1,000,000 or more)
Where random permutations of the
Similarly:
s - c(replicate(N, sample(3)))
Andy
From: roger koenker
One way:
N - 10
s - c(apply(matrix(rep(1:3,N),3,N),2,sample))
url:www.econ.uiuc.edu/~rogerRoger Koenker
email[EMAIL PROTECTED]Department of Economics
vox:
Thanks for all your suggestions!
I guess I'll have to make tests to see which one is faster :)
Will come back to you when it's done.
On 8/21/07, Liaw, Andy [EMAIL PROTECTED] wrote:
Similarly:
s - c(replicate(N, sample(3)))
Andy
From: roger koenker
One way:
N - 10
s -