<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/162541</link>
    <title>MATLAB Central Newsreader - compute (multimonial type) expression</title>
    <description>Feed for thread: compute (multimonial type) expression</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>Thu, 24 Jan 2008 01:10:41 -0500</pubDate>
      <title>compute (multimonial type) expression</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/162541#410998</link>
      <author>tenida@gmail.com</author>
      <description>I need to compute what is the probability of selecting k balls from N&lt;br&gt;
balls where ball j can be picked with prob p_j.&lt;br&gt;
&lt;br&gt;
Prob (k balls are picked) = \sum_{i_1}^N \sum_{i_2, i_2 not equal to&lt;br&gt;
i_1}^N......\sum_{i_k=1, i_k not equal to any of i_1,i_2,..,i_{k-1}}^N&lt;br&gt;
p_{i_1} p_{i_2}...p_{i_k} \Prod_{j not equal to i_1, i_2, ..,i_k} (1-&lt;br&gt;
p_j)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
how can I compute Prob (k) efficiently, it seems there are N choose K&lt;br&gt;
terms inside and for me N = 350 and K=10 ?&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Thu, 24 Jan 2008 05:12:02 -0500</pubDate>
      <title>Re: compute (multimonial type) expression</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/162541#411018</link>
      <author>Roger Stafford</author>
      <description>tenida@gmail.com wrote in message &amp;lt;22123f1d-a0b3-42f4-b685-&lt;br&gt;
cb52d0793a5b@x69g2000hsx.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; I need to compute what is the probability of selecting k balls from N&lt;br&gt;
&amp;gt; balls where ball j can be picked with prob p_j.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Prob (k balls are picked) = \sum_{i_1}^N \sum_{i_2, i_2 not equal to&lt;br&gt;
&amp;gt; i_1}^N......\sum_{i_k=1, i_k not equal to any of i_1,i_2,..,i_{k-1}}^N&lt;br&gt;
&amp;gt; p_{i_1} p_{i_2}...p_{i_k} \Prod_{j not equal to i_1, i_2, ..,i_k} (1-&lt;br&gt;
&amp;gt; p_j)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; how can I compute Prob (k) efficiently, it seems there are N choose K&lt;br&gt;
&amp;gt; terms inside and for me N = 350 and K=10 ?&lt;br&gt;
--------&lt;br&gt;
&amp;nbsp;&amp;nbsp;I would do this problem by using an iteration in N.  Set up vector t with k+2 &lt;br&gt;
elements in which after n steps in the iteration, the elements of t = [t(1),t(2),t&lt;br&gt;
(3),t(4),...,t(k+2)] are the probabilities of having selected -1,0,1,2,...,k balls &lt;br&gt;
from the first n balls, respectively.  Of course t(1) will always be zero since -1 &lt;br&gt;
is impossible, but the iteration is simplified if this zero is present.  In the &lt;br&gt;
beginning when n = 0 we must have t(2) = 1 and all other elements zero, &lt;br&gt;
since it is certain no balls have yet been selected.  Let p be the vector where p&lt;br&gt;
(j) is the probability of picking the j-th ball.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;t = zeros(1,k+2); t(2) = 1;&lt;br&gt;
&amp;nbsp;for j = 1:N&lt;br&gt;
&amp;nbsp;&amp;nbsp;t(2:k+2) = p(j)*t(1:k+1)+(1-p(j))*t(2:k+2);&lt;br&gt;
&amp;nbsp;end&lt;br&gt;
&amp;nbsp;&lt;br&gt;
Then t(end) emerges as the desired probability of having picked k balls out of &lt;br&gt;
all N balls.  Moreover, the elements t(end-1),t(end-2), ...,t(2) will be the &lt;br&gt;
probabilities of having picked k-1, k-2, ..., 0 balls, respectively.  If you set k &lt;br&gt;
= N, then t(2:end) will give the probabilities of having chosen any desired &lt;br&gt;
number of balls from 0 to N.&lt;br&gt;
&lt;br&gt;
Roger Stafford&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Thu, 24 Jan 2008 06:10:03 -0500</pubDate>
      <title>Re: compute (multimonial type) expression</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/162541#411022</link>
      <author>Roger Stafford</author>
      <description>"Roger Stafford" &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt; wrote in &lt;br&gt;
message &amp;lt;fn96n2$n9i$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; tenida@gmail.com wrote in message &amp;lt;22123f1d-a0b3-42f4-b685-&lt;br&gt;
&amp;gt; cb52d0793a5b@x69g2000hsx.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; I need to compute what is the probability of selecting k balls from N&lt;br&gt;
&amp;gt; &amp;gt; balls where ball j can be picked with prob p_j.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Prob (k balls are picked) = \sum_{i_1}^N \sum_{i_2, i_2 not equal to&lt;br&gt;
&amp;gt; &amp;gt; i_1}^N......\sum_{i_k=1, i_k not equal to any of i_1,i_2,..,i_{k-1}}^N&lt;br&gt;
&amp;gt; &amp;gt; p_{i_1} p_{i_2}...p_{i_k} \Prod_{j not equal to i_1, i_2, ..,i_k} (1-&lt;br&gt;
&amp;gt; &amp;gt; p_j)&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; how can I compute Prob (k) efficiently, it seems there are N choose K&lt;br&gt;
&amp;gt; &amp;gt; terms inside and for me N = 350 and K=10 ?&lt;br&gt;
&amp;gt; --------&lt;br&gt;
&amp;gt;   I would do this problem by using an iteration in N.  Set up vector t with k&lt;br&gt;
+2 &lt;br&gt;
&amp;gt; elements in which after n steps in the iteration, the elements of t = [t(1),t&lt;br&gt;
(2),t&lt;br&gt;
&amp;gt; (3),t(4),...,t(k+2)] are the probabilities of having selected -1,0,1,2,...,k balls &lt;br&gt;
&amp;gt; from the first n balls, respectively.  Of course t(1) will always be zero since &lt;br&gt;
-1 &lt;br&gt;
&amp;gt; is impossible, but the iteration is simplified if this zero is present.  In the &lt;br&gt;
&amp;gt; beginning when n = 0 we must have t(2) = 1 and all other elements zero, &lt;br&gt;
&amp;gt; since it is certain no balls have yet been selected.  Let p be the vector &lt;br&gt;
where p&lt;br&gt;
&amp;gt; (j) is the probability of picking the j-th ball.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  t = zeros(1,k+2); t(2) = 1;&lt;br&gt;
&amp;gt;  for j = 1:N&lt;br&gt;
&amp;gt;   t(2:k+2) = p(j)*t(1:k+1)+(1-p(j))*t(2:k+2);&lt;br&gt;
&amp;gt;  end&lt;br&gt;
&amp;gt;  &lt;br&gt;
&amp;gt; Then t(end) emerges as the desired probability of having picked k balls out &lt;br&gt;
of &lt;br&gt;
&amp;gt; all N balls.  Moreover, the elements t(end-1),t(end-2), ...,t(2) will be the &lt;br&gt;
&amp;gt; probabilities of having picked k-1, k-2, ..., 0 balls, respectively.  If you set &lt;br&gt;
k &lt;br&gt;
&amp;gt; = N, then t(2:end) will give the probabilities of having chosen any desired &lt;br&gt;
&amp;gt; number of balls from 0 to N.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger Stafford&lt;br&gt;
-----&lt;br&gt;
&amp;nbsp;&amp;nbsp;In case it will give you more confidence in the reasoning here, I should point &lt;br&gt;
out that the above procedure is a simple generalization of the algorithm &lt;br&gt;
involved in generating Pascal triangles for values nCk.&lt;br&gt;
&lt;br&gt;
Roger Stafford&lt;br&gt;
&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
