Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to generate all vectors of length n with entries are 0's or 1's then sum over
Date: Tue, 13 Jul 2010 19:05:21 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 39
Message-ID: <i1iddh$iq6$1@fred.mathworks.com>
References: <i1iafp$6v7$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1279047921 19270 172.30.248.35 (13 Jul 2010 19:05:21 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 13 Jul 2010 19:05:21 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:652801

"yang " <macmaster_egypt@yahoogroups.com> wrote in message <i1iafp$6v7$1@fred.mathworks.com>...
> Hi,
> I need your help for this problem, please.
> 
> \mathop  {\sum {...\sum }}\limits_{z_r \in {Q_{2}^{*}}} such that 
> 
> Q_{2}^{*}=\{(z_1,...,z_r):z_{j}=0,1,\sum_{j=1}^{r}z_{j}=\ell\}, where \ell = 0, 1, . . . , r.
> 
> For example. If r=3, \ell=1; then we are looking for triples with elements 0's or 1's and sum to 1 i.e. Q_{2}^{*}=\{(0,0,1),(0,1,0),(1,0,0)\}. So we would like to sum over theses z_r's.
> 
> I appreciate your help.
> Adam 
- - - - - - - -
  If I interpret your question correctly, for r = 5 and ell = 3, you first want all sequences of five 0's or 1's whose sum is 3:

 0 0 1 1 1
 0 1 0 1 1
 0 1 1 0 1
 0 1 1 1 0
 1 0 0 1 1
 1 0 1 0 1
 1 0 1 1 0
 1 1 0 0 1
 1 1 0 1 0
 1 1 1 0 0

Next you want the sum of each of these columns.  Is that right?

  You don't need matlab for that trivial problem.  The answer is always

 (r-1)!/(ell-1)!/(r-ell)!

for each column.  In the above case this is 4!/2!/2! = 6 which is clearly correct.

  Or, if you want the sum over all elements of all sequences, it would be

 r!/(ell-1)!/(r-ell)!

Roger Stafford