Hi
How do I generate all ways of ordering sets of indistinguishable items?
suppose I have two A's, two B's and a C.
Then I want
AABBC
AABCB
AACBC
ABABC
. . .snip...
BBAAC
. . .snip...
CBBAA
[there are 5!/(2!*2!) = 30 arrangements. Note AABBC != BBAAC]
How do I do this?
--
Robin Hankin
quot;ACBAB" "BACAB" "ABCAB" "CAABB" "ACABB"
"AACBB" "BAACB"
[23] "ABACB" "AABCB" "BBAAC" "BABAC" "ABBAC" "BAABC" "ABABC" "AABBC"
> length(res)
[1] 30
"BAACB"
> [23] "ABACB" "AABCB" "BBAAC" "BABAC" "ABBAC" "BAABC" "ABABC" "AABBC"
>> length(res)
> [1] 30
>
> -Christos
>
> Christos Hatzis, Ph.D.
> Nuvera Biosciences, Inc.
> 400
Use 'permutations' in 'gtools'
x <- permutations(5,5)
y <- c('a','a','b','b','c')[x]
dim(y) <- dim(x)
unique(y)
On 10/13/06, Robin Hankin <[EMAIL PROTECTED]> wrote:
> Hi
>
> How do I generate all ways of ordering sets of indistinguishable items?
>
> suppose I have two A's, two B's and a C.
>
>
On 13-Oct-06 Robin Hankin wrote:
> Hi
>
> How do I generate all ways of ordering sets of indistinguishable
> items?
>
> suppose I have two A's, two B's and a C.
>
> Then I want
>
> AABBC
> AABCB
> AACBC >> I think you mean AACBB here!
> ABABC
> . . .snip...
> BBAAC
> . . .snip...
> CBBAA
>
On Fri, 13 Oct 2006, Robin Hankin wrote:
> Hi
>
> How do I generate all ways of ordering sets of indistinguishable items?
>
> suppose I have two A's, two B's and a C.
>
> Then I want
>
> AABBC
> AABCB
> AACBC
> ABABC
> . . .snip...
> BBAAC
> . . .snip...
> CBBAA
>
> [there are 5!/(2!*2!) = 30 arr
> I've tried to think of an efficient and economical (and therefore
> clever) way of doing this for larger problems; but that will have
> to wait for another day!
The ruby permutations library
(http://permutation.rubyforge.org/doc/index.html) references The
Algorithm Design Manual, Steven S. Skie
"ACBBA"
>>"BACBA" "ABCBA"
>>"BBACA" "BABCA"
>>[12] "ABBCA" "CBAAB" "BCAAB" "CABAB" "ACBAB" "BACAB" "ABCAB"
>>"CAABB" "ACABB"
>>"AACBB&
Robin Hankin <[EMAIL PROTECTED]> writes:
> Hi
>
> How do I generate all ways of ordering sets of indistinguishable items?
>
> suppose I have two A's, two B's and a C.
>
> Then I want
>
> AABBC
> AABCB
> AACBC
> ABABC
> . . .snip...
> BBAAC
> . . .snip...
> CBBAA
>
> [there are 5!/(2!*2!) = 30 arr
Hi
I want to enumerate all vectors of length "J", whose elements are
integers in the range 1 to S, without regard to ordering.
With J=S=3, the combinations are as follows:
[,1] [,2] [,3]
[1,]111
[2,]112
[3,]113
[4,]122
[5,]1
> library(gtools)
> combinations(5,3)
[,1] [,2] [,3]
[1,]123
[2,]124
[3,]125
[4,]134
[5,]135
[6,]145
[7,]234
[8,]235
[9,]245
[10,]345
Robin Hankin a écrit :
>H
Thank you Jacques
but your solution misses (eg) c(1,1,2) which I need.
best wishes
Robin
On 6 Mar 2006, at 09:17, Jacques VESLOT wrote:
> > library(gtools)
> > combinations(5,3)
> [,1] [,2] [,3]
> [1,]123
> [2,]124
> [3,]125
> [4,]134
> [
Robin Hankin wrote:
> Thank you Jacques
>
> but your solution misses (eg) c(1,1,2) which I need.
See ?combinations which should point you to
combinations(5,3, repeats.allowed=TRUE)
Best,
Uwe
> best wishes
>
> Robin
>
>
>
> On 6 Mar 2006, at 09:17, Jacques VESLOT wrote:
>
>
>>>library
combinations(5,3,rep=T)
Robin Hankin a écrit :
> Thank you Jacques
>
> but your solution misses (eg) c(1,1,2) which I need.
>
> best wishes
>
> Robin
>
>
>
> On 6 Mar 2006, at 09:17, Jacques VESLOT wrote:
>
>> > library(gtools)
>> > combinations(5,3)
>> [,1] [,2] [,3]
>> [1,]123
Patrick, Uwe
thanks!
[both your solutions were conceptually identical, except for one
was "ascending" and one was "descending"]
very best wishes
Robin
On 6 Mar 2006, at 09:36, Uwe Ligges wrote:
> Robin Hankin wrote:
>
>> Thank you Jacques
>>
>> but your solution misses (eg) c(1,1,2) which
15 matches
Mail list logo