Path: news.mathworks.com!not-for-mail
From: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
Newsgroups: comp.soft-sys.matlab
Subject: Re: eliminate identical raws
Date: Sat, 16 Feb 2008 16:58:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 50
Message-ID: <fp74mq$d7n$1@fred.mathworks.com>
References: <27823314.1203129850043.JavaMail.jakarta@nitrogen.mathforum.org> <fp710n$32a$1@fred.mathworks.com>
Reply-To: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1203181082 13559 172.30.248.37 (16 Feb 2008 16:58:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 16 Feb 2008 16:58:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:451834


"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in 
message <fp710n$32a$1@fred.mathworks.com>...
> ..........
>   A note of caution.  Unfortunately I don't have 'nchoosek' to experiment 
with 
> on my system, and there is one aspect of it that is worrisome.  In their 
> documentation MathWorks gives the same "practical" limit on the use of 
> 'nchoosek' as it does for 'perms', namely that n ought not to exceed 15.  
One 
> would think that 'nchoosek' ought to be able to deal with considerably 
larger 
> values of n than this without encountering the difficulties of 'perms'.  This 
> would appear to suggest that perhaps 'nchoosek' also does something 
crude 
> like a 'perms' operation followed by a call to 'unique', in which case there 
> would be no particular advantage to using 'nchoosek' as given above.  A 
huge 
> array would be created in either case.  Can anyone in this group tell me if 
that 
> is true?
> 
> Roger Stafford
---------
  Vladimir, I've just been reading John D'Errico's description of his loop 
version of 'nchoosek' at

 <http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?
objectId=13276>

which he calls 'loopchoose'.  In it he mentions that the call nchoosek(1:20,10) 
takes only 18.35 seconds on his computer.  That puts to rest the worries I 
mentioned earlier.  If it were to first create a 'perms' type output, it would 
generate 20! = 2.4e20 rows, which clearly could not have happened in 18.35 
seconds nor in any computer known to man.  So you can forget what I said in 
that last paragraph.  MathWorks needs to correct their documentation.  You 
should be able to use 'nchoosek' effectively for the larger values of p and q.

  For more than two different numbers in your original array, let's say p of 
one, q of another, r of another, etc., the total number of distinct rows would 
be:

 (p+q+r+...)/(p!*q!*r!*...) .

I think an iterative process could be devised that would solve your problem in 
such a case with multiple calls on 'nchoosek'.  However, I couldn't tell from 
your question just how general a problem you are faced with.

Roger Stafford