s-news
[Top] [All Lists]

Re: permutation

To: "Reyderman, Larisa" <larisa.reyderman@spcorp.com>
Subject: Re: permutation
From: Sundar Dorai-Raj <sundar.dorai-raj@pdf.com>
Date: Thu, 14 Apr 2005 16:17:00 -0500
Cc: "'s-news@lists.biostat.wustl.edu'" <s-news@lists.biostat.wustl.edu>
In-reply-to: <51E9450E2DA1D4118DB400508BF9AC34169EDE7A@kenmsg32.schp.com>
Organization: PDF Solutions, Inc.
References: <51E9450E2DA1D4118DB400508BF9AC34169EDE7A@kenmsg32.schp.com>
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)


Reyderman, Larisa wrote on 4/14/2005 3:54 PM:
Dear All,

I have a seemingly easy question.  I need to create a matrix consisting of
all possible permutations of the following vector:

0.5  1.0  1.5  2.0  3.0  4.0  5.0  6.0  8.0 10.0 12.0 16.0

I know that "sample" function with (replace=F) will generate a permutation,
however, I need all possible permutations.

Thank you for your help.

Larisa



If you have access to R then there's a package called gtools (part of the gregmisc bundle) that has a function to do this. I'm sure it's easily ported to S-PLUS. However, with your problem 12 values gives 12! possible permutations, or nearly 480 million possibilities. Are you sure you want *all* permutations? If so, consider doing this in C.

--sundar

<Prev in Thread] Current Thread [Next in Thread>