<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168839</link>
    <title>MATLAB Central Newsreader - Number of unique combinations from sets</title>
    <description>Feed for thread: Number of unique combinations from sets</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 07 May 2008 10:31:04 -0400</pubDate>
      <title>Re: Number of unique combinations from sets</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168839#430788</link>
      <author>Jos </author>
      <description>"helper " &amp;lt;spamless@nospam.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;fvrfo5$l1l$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
...&lt;br&gt;
&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Jos should probably just call ALLCOMB from COMBN.  COMBN &lt;br&gt;
&amp;gt; just allows you to use:&lt;br&gt;
&lt;br&gt;
Thanks for this suggestion.&lt;br&gt;
&lt;br&gt;
Jos&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 07 May 2008 06:58:03 -0400</pubDate>
      <title>Re: Number of unique combinations from sets</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168839#430754</link>
      <author>Daniel </author>
      <description>"Roger Stafford" &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt;&lt;br&gt;
wrote in message &amp;lt;fvri01$ghb$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;   There is something sorely amiss with your coding if it &lt;br&gt;
&amp;gt; takes six days to cover all the combinations of the kind &lt;br&gt;
&amp;nbsp;&amp;gt; you want with only the sets&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  [1:900], [1:900], [1:2]&lt;br&gt;
&amp;gt; There are only 1620000 different combinations altogether&lt;br&gt;
from these sets, &lt;br&gt;
&amp;gt; even considering all as being different.  That is not very&lt;br&gt;
many to go through &lt;br&gt;
&amp;gt; for a computer unless you have RAM storage problems!  It&lt;br&gt;
ought to finish up &lt;br&gt;
&amp;gt; in only a few seconds.&lt;br&gt;
&amp;nbsp;&lt;br&gt;
Yes, the only way i could think to do it was to call allcomb&lt;br&gt;
and then search through the output for permutations (what&lt;br&gt;
the code in the first post does). Which I think would make&lt;br&gt;
1620000 * 6...at any rate the script above isn't efficient&lt;br&gt;
in any respects (hence, my post :-)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt;   I am still striving for a precise general definition of&lt;br&gt;
what it is you are after.  &lt;br&gt;
&amp;gt; If you have set1, set2, set3, ..., setn as n sets of&lt;br&gt;
integers, then the integer &lt;br&gt;
&amp;gt; sequence a1, a2, a3, ..., an, should appear whenever 1)&lt;br&gt;
each ai belongs to &lt;br&gt;
&amp;gt; seti, and 2) if any ai and aj pair both belong to each of&lt;br&gt;
seti and setj, then if i &lt;br&gt;
&amp;gt; &amp;lt; j, we have ai &amp;lt;= aj.  In other words any pair of&lt;br&gt;
integers that both come &lt;br&gt;
&amp;gt; from each of two sets should always appear in ascending&lt;br&gt;
order.  Does that &lt;br&gt;
&amp;gt; accurately define what you are after?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;   If so, I would think you could just use 'allcomb' first&lt;br&gt;
and subsequently delete &lt;br&gt;
&amp;gt; all those which failed this second condition.  The&lt;br&gt;
rejection rate should not be &lt;br&gt;
&amp;gt; excessive until the number of sets gets too large.&lt;br&gt;
&lt;br&gt;
Yes, I think you're description is correct. Certainly, the&lt;br&gt;
method you describe for finding a solution works and is&lt;br&gt;
essentially what's happening when you call...&lt;br&gt;
&lt;br&gt;
a = unique(sort(allcomb(1:a, 1:b, 1:c), 2), 'rows);&lt;br&gt;
&lt;br&gt;
I had forgotten about the sort function and all I could&lt;br&gt;
remember was sortrows, which obviously doesn't do what is&lt;br&gt;
needed. Thanks for you help.&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 07 May 2008 06:25:05 -0400</pubDate>
      <title>Re: Number of unique combinations from sets</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168839#430747</link>
      <author>Roger Stafford</author>
      <description>"Daniel " &amp;lt;danielDOTrDOTlittle@gmail.com&amp;gt; wrote in message &amp;lt;fvr755$inh&lt;br&gt;
$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hello,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'm looking for a fast method of finding all of the unique &lt;br&gt;
&amp;gt; combinations of sets of elements (assuming that all sets &lt;br&gt;
&amp;gt; are the same). &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; To give an example by contrast, the Matlab File Exchange &lt;br&gt;
&amp;gt; file 'allcomb' generates all unique combinations of sets of &lt;br&gt;
&amp;gt; elements assuming taht all the sets are different), so:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; allcomb([1:3], [1:3])&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ans =&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;      1     1&lt;br&gt;
&amp;gt;      1     2&lt;br&gt;
&amp;gt;      1     3&lt;br&gt;
&amp;gt;      2     1&lt;br&gt;
&amp;gt;      2     2&lt;br&gt;
&amp;gt;      2     3&lt;br&gt;
&amp;gt;      3     1&lt;br&gt;
&amp;gt;      3     2&lt;br&gt;
&amp;gt;      3     3&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; what I want is:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ans = &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;      1     1&lt;br&gt;
&amp;gt;      1     2&lt;br&gt;
&amp;gt;      1     3&lt;br&gt;
&amp;gt;      2     2&lt;br&gt;
&amp;gt;      2     3&lt;br&gt;
&amp;gt;      3     3&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; A short script which achieves this is (where hyps is the &lt;br&gt;
&amp;gt; outcome of interest):&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; x = allcomb([1:3], [1:3]);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; hyps = x(1,:);&lt;br&gt;
&amp;gt; for i = 2:size(x, 1)&lt;br&gt;
&amp;gt;     t = x(i,:);&lt;br&gt;
&amp;gt;     test = perms(t);&lt;br&gt;
&amp;gt;     for j = 1:size(test,1)&lt;br&gt;
&amp;gt;         tr(j) = any(all(repmat(test(j,:),...&lt;br&gt;
&amp;gt;                 size(hyps,1), 1) == hyps,2));&lt;br&gt;
&amp;gt;     end&lt;br&gt;
&amp;gt;     if sum(tr) == 0&lt;br&gt;
&amp;gt;         hyps = [hyps; x(i,:)];&lt;br&gt;
&amp;gt;     end&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; However, this process is painfully slow for large sets &lt;br&gt;
&amp;gt; (e.g., [1:900], [1:900], [1:2] takes 6 days to complete!).&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Any advice on how to speed this process up or direction &lt;br&gt;
&amp;gt; towards an existing function would be greatly appreciated.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Dan&lt;br&gt;
------------&lt;br&gt;
&amp;nbsp;&amp;nbsp;There is something sorely amiss with your coding if it takes six days to &lt;br&gt;
cover all the combinations of the kind you want with only the sets&lt;br&gt;
&lt;br&gt;
&amp;nbsp;[1:900], [1:900], [1:2]&lt;br&gt;
&lt;br&gt;
There are only 1620000 different combinations altogether from these sets, &lt;br&gt;
even considering all as being different.  That is not very many to go through &lt;br&gt;
for a computer unless you have RAM storage problems!  It ought to finish up &lt;br&gt;
in only a few seconds.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;I am still striving for a precise general definition of what it is you are after.  &lt;br&gt;
If you have set1, set2, set3, ..., setn as n sets of integers, then the integer &lt;br&gt;
sequence a1, a2, a3, ..., an, should appear whenever 1) each ai belongs to &lt;br&gt;
seti, and 2) if any ai and aj pair both belong to each of seti and setj, then if i &lt;br&gt;
&amp;lt; j, we have ai &amp;lt;= aj.  In other words any pair of integers that both come &lt;br&gt;
from each of two sets should always appear in ascending order.  Does that &lt;br&gt;
accurately define what you are after?&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;If so, I would think you could just use 'allcomb' first and subsequently delete &lt;br&gt;
all those which failed this second condition.  The rejection rate should not be &lt;br&gt;
excessive until the number of sets gets too large.&lt;br&gt;
&lt;br&gt;
Roger Stafford&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 07 May 2008 06:14:07 -0400</pubDate>
      <title>Re: Number of unique combinations from sets</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168839#430746</link>
      <author>Daniel </author>
      <description>"helper " &amp;lt;spamless@nospam.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;fvrfo5$l1l$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; "Daniel " &amp;lt;danielDOTrDOTlittle@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; &amp;lt;fvrc2j$rtm$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; OK.  I guess you might want all combinations but where &lt;br&gt;
&amp;gt; order is unimportant.  Playing with ALLCOMB, it is much &lt;br&gt;
&amp;gt; better than COMBSREP.  Here is a quick adjustment you can &lt;br&gt;
&amp;gt; make to the output of ALLCOMB to obtain what you are &lt;br&gt;
&amp;gt; looking for:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; tic&lt;br&gt;
&amp;gt; a = unique(sort(allcomb(1:900,1:900),2),'rows');&lt;br&gt;
&amp;gt; toc&lt;br&gt;
&amp;gt; Elapsed time is 0.927414 seconds.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thanks so much. I didn't think to sort the columns first&lt;br&gt;
before calling unique. Good stuff.&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 07 May 2008 05:46:45 -0400</pubDate>
      <title>Re: Number of unique combinations from sets</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168839#430743</link>
      <author>helper </author>
      <description>"Daniel " &amp;lt;danielDOTrDOTlittle@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;lt;fvrc2j$rtm$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&lt;br&gt;
OK.  I guess you might want all combinations but where &lt;br&gt;
order is unimportant.  Playing with ALLCOMB, it is much &lt;br&gt;
better than COMBSREP.  Here is a quick adjustment you can &lt;br&gt;
make to the output of ALLCOMB to obtain what you are &lt;br&gt;
looking for:&lt;br&gt;
&lt;br&gt;
tic&lt;br&gt;
a = unique(sort(allcomb(1:900,1:900),2),'rows');&lt;br&gt;
toc&lt;br&gt;
Elapsed time is 0.927414 seconds.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
In fact, the same author (Jos van der Geest) has a &lt;br&gt;
different function called COMBN which appears to be &lt;br&gt;
specific to drawing combinations from the same set (without &lt;br&gt;
replacement).  However, it is slowing than ALLCOMB when &lt;br&gt;
given the same set:&lt;br&gt;
&lt;br&gt;
tic&lt;br&gt;
a = allcomb(1:900,1:900);&lt;br&gt;
toc&lt;br&gt;
Elapsed time is 0.075114 seconds.&lt;br&gt;
&lt;br&gt;
tic&lt;br&gt;
b = combn(1:900,2);&lt;br&gt;
toc&lt;br&gt;
Elapsed time is 0.399549 seconds.&lt;br&gt;
&lt;br&gt;
isequal(a,b)&lt;br&gt;
&lt;br&gt;
ans =&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;br&gt;
&lt;br&gt;
Jos should probably just call ALLCOMB from COMBN.  COMBN &lt;br&gt;
just allows you to use:&lt;br&gt;
&lt;br&gt;
combn(1:20,4)&lt;br&gt;
&lt;br&gt;
rather than having to use:&lt;br&gt;
&lt;br&gt;
allcomb(1:20,1:20,1:20,1:20)&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 07 May 2008 05:36:03 -0400</pubDate>
      <title>Re: Number of unique combinations from sets</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168839#430741</link>
      <author>Daniel </author>
      <description>&amp;gt; In this example, it looks like you have two sets(1:3 and &lt;br&gt;
&amp;gt; 1:4), selecting 1 item from each set.  Why is [2 1] not a &lt;br&gt;
&amp;gt; valid combination then?  &lt;br&gt;
&lt;br&gt;
Ok, this problem came about because I was trying to find a&lt;br&gt;
way to determine how many cuboids of size a x b x c will fit&lt;br&gt;
into a larger cuboid of size m x n x p. For this problem, a&lt;br&gt;
x b x c is equivalent to a x c x b or b x a x c, etc. So&lt;br&gt;
rotation of the cuboid shape doesn't matter. &lt;br&gt;
&lt;br&gt;
So, if I want to find all potentially valid combinations of&lt;br&gt;
a x b x c that will fit into a larger shape m x n x p, then&lt;br&gt;
I have to consider all combinations of the sets [1:m], [1:n]&lt;br&gt;
and [1:p], but since rotation doesn't matter I need to&lt;br&gt;
eliminate any combinations where a x b x c can be created by&lt;br&gt;
permuting the elements in c x b x a or a x c x b or b x a x&lt;br&gt;
c, etc. &lt;br&gt;
&lt;br&gt;
Hence, I need allcomb but with the non-unique permutations&lt;br&gt;
removed. So, [1 2] is valid but [2 1] is not valid because&lt;br&gt;
the reversing the elements of [2 1] equals [1 2]. Does that&lt;br&gt;
help at all?  &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt; I could come up with some code that will do this, but I &lt;br&gt;
&amp;gt; don't think this is really what you want to do.  Maybe you &lt;br&gt;
&amp;gt; can explain further.&lt;br&gt;
&lt;br&gt;
The script listed in my original post is correct and will do&lt;br&gt;
what I need, but it's incredibly slow for large set sizes. &lt;br&gt;
&lt;br&gt;
Hope that clarifies the issue a little.&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 07 May 2008 05:05:05 -0400</pubDate>
      <title>Re: Number of unique combinations from sets</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168839#430736</link>
      <author>helper </author>
      <description>"Daniel " &amp;lt;danielDOTrDOTlittle@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;lt;fvrc2j$rtm$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; You are looking for all combinations with replacement.  &lt;br&gt;
&amp;gt; &amp;gt; Check out the file COMBSREP.m at the following link:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;a href="http://www.mathworks.com/support/solutions/files/s36265/"&gt;http://www.mathworks.com/support/solutions/files/s36265/&lt;/a&gt;&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; combsrep(1:3, 2)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 'combsrep' will work if the sets I'm comparing are all the&lt;br&gt;
&amp;gt; same, but it lacks the functionality of 'allcomb', which&lt;br&gt;
&amp;gt; allows the sets to contain different elements. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; So to give another example:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; allcomb([1:3], [1:4])&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ans =&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;      1     1&lt;br&gt;
&amp;gt;      1     2&lt;br&gt;
&amp;gt;      1     3&lt;br&gt;
&amp;gt;      1     4&lt;br&gt;
&amp;gt;      2     1&lt;br&gt;
&amp;gt;      2     2&lt;br&gt;
&amp;gt;      2     3&lt;br&gt;
&amp;gt;      2     4&lt;br&gt;
&amp;gt;      3     1&lt;br&gt;
&amp;gt;      3     2&lt;br&gt;
&amp;gt;      3     3&lt;br&gt;
&amp;gt;      3     4&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; But I need:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ans =&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;      1     1&lt;br&gt;
&amp;gt;      1     2&lt;br&gt;
&amp;gt;      1     3&lt;br&gt;
&amp;gt;      1     4&lt;br&gt;
&amp;gt;      2     2&lt;br&gt;
&amp;gt;      2     3&lt;br&gt;
&amp;gt;      2     4&lt;br&gt;
&amp;gt;      3     3&lt;br&gt;
&amp;gt;      3     4&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I don't think I can do this with combsrep (or am I missing&lt;br&gt;
&amp;gt; something)?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks for the link though (and thanks to anyone else &lt;br&gt;
who's&lt;br&gt;
&amp;gt; replied), combsrep looks like a useful function anway. &lt;br&gt;
&lt;br&gt;
I don't understand what you are asking for then.  Your &lt;br&gt;
first example looked like you were selecting an item from a &lt;br&gt;
set, replacing it, then selecting again.&lt;br&gt;
&lt;br&gt;
In this example, it looks like you have two sets(1:3 and &lt;br&gt;
1:4), selecting 1 item from each set.  Why is [2 1] not a &lt;br&gt;
valid combination then?  Are you saying the second set &lt;br&gt;
changes based on your selection of the first set?  All &lt;br&gt;
elements of the second set which are smaller than the value &lt;br&gt;
of your selection in the first set disappear?&lt;br&gt;
&lt;br&gt;
I could come up with some code that will do this, but I &lt;br&gt;
don't think this is really what you want to do.  Maybe you &lt;br&gt;
can explain further.&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 07 May 2008 04:44:03 -0400</pubDate>
      <title>Re: Number of unique combinations from sets</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168839#430731</link>
      <author>Daniel </author>
      <description>&amp;gt; You are looking for all combinations with replacement.  &lt;br&gt;
&amp;gt; Check out the file COMBSREP.m at the following link:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;a href="http://www.mathworks.com/support/solutions/files/s36265/"&gt;http://www.mathworks.com/support/solutions/files/s36265/&lt;/a&gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; combsrep(1:3, 2)&lt;br&gt;
&lt;br&gt;
'combsrep' will work if the sets I'm comparing are all the&lt;br&gt;
same, but it lacks the functionality of 'allcomb', which&lt;br&gt;
allows the sets to contain different elements. &lt;br&gt;
&lt;br&gt;
So to give another example:&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; allcomb([1:3], [1:4])&lt;br&gt;
&lt;br&gt;
ans =&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1     1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1     2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1     3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1     4&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2     1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2     2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2     3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2     4&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3     1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3     2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3     3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3     4&lt;br&gt;
&lt;br&gt;
But I need:&lt;br&gt;
&lt;br&gt;
ans =&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1     1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1     2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1     3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1     4&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2     2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2     3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2     4&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3     3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3     4&lt;br&gt;
&lt;br&gt;
I don't think I can do this with combsrep (or am I missing&lt;br&gt;
something)?&lt;br&gt;
&lt;br&gt;
Thanks for the link though (and thanks to anyone else who's&lt;br&gt;
replied), combsrep looks like a useful function anway. &lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 07 May 2008 04:13:03 -0400</pubDate>
      <title>Re: Number of unique combinations from sets</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168839#430722</link>
      <author>helper </author>
      <description>&amp;gt;   I believe the call&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  c = nchoosek(1:n,k);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; does just what you want for k numbers chosen out of 1:n&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger Stafford&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
NCHOOSEK only gives combinations *without* replacement, so &lt;br&gt;
he won't get the &lt;br&gt;
&lt;br&gt;
1 1&lt;br&gt;
2 2&lt;br&gt;
3 3&lt;br&gt;
&lt;br&gt;
elements.&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 07 May 2008 04:08:03 -0400</pubDate>
      <title>Re: Number of unique combinations from sets</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168839#430721</link>
      <author>Roger Stafford</author>
      <description>"Daniel " &amp;lt;danielDOTrDOTlittle@gmail.com&amp;gt; wrote in message &amp;lt;fvr755$inh&lt;br&gt;
$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hello,&lt;br&gt;
&amp;gt; I'm looking for a fast method of finding all of the unique &lt;br&gt;
&amp;gt; combinations of sets of elements (assuming that all sets &lt;br&gt;
&amp;gt; are the same). &lt;br&gt;
&amp;gt; .......&lt;br&gt;
&amp;gt; Dan&lt;br&gt;
-------&lt;br&gt;
&amp;nbsp;&amp;nbsp;I believe the call&lt;br&gt;
&lt;br&gt;
&amp;nbsp;c = nchoosek(1:n,k);&lt;br&gt;
&lt;br&gt;
does just what you want for k numbers chosen out of 1:n&lt;br&gt;
&lt;br&gt;
Roger Stafford&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 07 May 2008 03:51:03 -0400</pubDate>
      <title>Re: Number of unique combinations from sets</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168839#430714</link>
      <author>helper </author>
      <description>"Daniel " &amp;lt;danielDOTrDOTlittle@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;lt;fvr755$inh$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hello,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'm looking for a fast method of finding all of the &lt;br&gt;
unique &lt;br&gt;
&amp;gt; combinations of sets of elements (assuming that all sets &lt;br&gt;
&amp;gt; are the same). &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; To give an example by contrast, the Matlab File Exchange &lt;br&gt;
&amp;gt; file 'allcomb' generates all unique combinations of sets &lt;br&gt;
of &lt;br&gt;
&amp;gt; elements assuming taht all the sets are different), so:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; allcomb([1:3], [1:3])&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ans =&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;      1     1&lt;br&gt;
&amp;gt;      1     2&lt;br&gt;
&amp;gt;      1     3&lt;br&gt;
&amp;gt;      2     1&lt;br&gt;
&amp;gt;      2     2&lt;br&gt;
&amp;gt;      2     3&lt;br&gt;
&amp;gt;      3     1&lt;br&gt;
&amp;gt;      3     2&lt;br&gt;
&amp;gt;      3     3&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; what I want is:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ans = &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;      1     1&lt;br&gt;
&amp;gt;      1     2&lt;br&gt;
&amp;gt;      1     3&lt;br&gt;
&amp;gt;      2     2&lt;br&gt;
&amp;gt;      2     3&lt;br&gt;
&amp;gt;      3     3&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; A short script which achieves this is (where hyps is the &lt;br&gt;
&amp;gt; outcome of interest):&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; x = allcomb([1:3], [1:3]);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; hyps = x(1,:);&lt;br&gt;
&amp;gt; for i = 2:size(x, 1)&lt;br&gt;
&amp;gt;     t = x(i,:);&lt;br&gt;
&amp;gt;     test = perms(t);&lt;br&gt;
&amp;gt;     for j = 1:size(test,1)&lt;br&gt;
&amp;gt;         tr(j) = any(all(repmat(test(j,:),...&lt;br&gt;
&amp;gt;                 size(hyps,1), 1) == hyps,2));&lt;br&gt;
&amp;gt;     end&lt;br&gt;
&amp;gt;     if sum(tr) == 0&lt;br&gt;
&amp;gt;         hyps = [hyps; x(i,:)];&lt;br&gt;
&amp;gt;     end&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; However, this process is painfully slow for large sets &lt;br&gt;
&amp;gt; (e.g., [1:900], [1:900], [1:2] takes 6 days to complete!).&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Any advice on how to speed this process up or direction &lt;br&gt;
&amp;gt; towards an existing function would be greatly appreciated.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Dan&lt;br&gt;
&lt;br&gt;
You are looking for all combinations with replacement.  &lt;br&gt;
Check out the file COMBSREP.m at the following link:&lt;br&gt;
&lt;br&gt;
&lt;a href="http://www.mathworks.com/support/solutions/files/s36265/"&gt;http://www.mathworks.com/support/solutions/files/s36265/&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
combsrep(1:3, 2)&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 07 May 2008 03:20:05 -0400</pubDate>
      <title>Number of unique combinations from sets</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168839#430711</link>
      <author>Daniel </author>
      <description>Hello,&lt;br&gt;
&lt;br&gt;
I'm looking for a fast method of finding all of the unique &lt;br&gt;
combinations of sets of elements (assuming that all sets &lt;br&gt;
are the same). &lt;br&gt;
&lt;br&gt;
To give an example by contrast, the Matlab File Exchange &lt;br&gt;
file 'allcomb' generates all unique combinations of sets of &lt;br&gt;
elements assuming taht all the sets are different), so:&lt;br&gt;
&lt;br&gt;
allcomb([1:3], [1:3])&lt;br&gt;
&lt;br&gt;
ans =&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1     1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1     2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1     3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2     1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2     2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2     3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3     1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3     2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3     3&lt;br&gt;
&lt;br&gt;
what I want is:&lt;br&gt;
&lt;br&gt;
ans = &lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1     1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1     2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1     3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2     2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2     3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3     3&lt;br&gt;
&lt;br&gt;
A short script which achieves this is (where hyps is the &lt;br&gt;
outcome of interest):&lt;br&gt;
&lt;br&gt;
x = allcomb([1:3], [1:3]);&lt;br&gt;
&lt;br&gt;
hyps = x(1,:);&lt;br&gt;
for i = 2:size(x, 1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;t = x(i,:);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;test = perms(t);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for j = 1:size(test,1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tr(j) = any(all(repmat(test(j,:),...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;size(hyps,1), 1) == hyps,2));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if sum(tr) == 0&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;hyps = [hyps; x(i,:)];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
However, this process is painfully slow for large sets &lt;br&gt;
(e.g., [1:900], [1:900], [1:2] takes 6 days to complete!).&lt;br&gt;
&lt;br&gt;
Any advice on how to speed this process up or direction &lt;br&gt;
towards an existing function would be greatly appreciated.&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
Dan&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
