<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: enter numbers into a matrix in a do loop - specific example in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/enter-numbers-into-a-matrix-in-a-do-loop-specific-example/m-p/329986#M3249</link>
    <description>&lt;P&gt;Hi Rick (I knew you would reply!)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By count I mean simply the total number of trials for which all 6 faces appear in 6 rolls, in 7 rolls, 8 rolls etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know that I can multiply each cdf by 10000 and then calculate the difference between consecutive cdf's, but I just wanted to see how to do it with the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Sat, 04 Feb 2017 23:08:53 GMT</pubDate>
    <dc:creator>ilikesas</dc:creator>
    <dc:date>2017-02-04T23:08:53Z</dc:date>
    <item>
      <title>enter numbers into a matrix in a do loop - specific example</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/enter-numbers-into-a-matrix-in-a-do-loop-specific-example/m-p/329981#M3247</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am recreating Rick Wicklin's blog post &lt;A href="http://blogs.sas.com/content/iml/2011/07/22/simulating-the-coupon-collectors-problem.html" target="_self"&gt;Simulating the Coupon Collector's Problem&lt;/A&gt;. In the last section there is a code that creates a CDF:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/** has event occurred by roll j? (j=K..L) **/
cdf = j(L,1,0); /** allocate **/
do j = K to L;
   c = countunique(x[,1:j], "row");
   cdf[j] = (c=K)[:];
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;H1 class="entry-title"&gt;&amp;nbsp;&lt;/H1&gt;
&lt;P&gt;What I would like &amp;nbsp;is to have the actual count for each j and not the proportion, but when I did :&lt;/P&gt;
&lt;P&gt;cdf[j] = c, I got an error message that the matrices do not conform to the operation. Is there a way to see the actual count for each j?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2017 21:52:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/enter-numbers-into-a-matrix-in-a-do-loop-specific-example/m-p/329981#M3247</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2017-02-04T21:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: enter numbers into a matrix in a do loop - specific example</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/enter-numbers-into-a-matrix-in-a-do-loop-specific-example/m-p/329984#M3248</link>
      <description>&lt;P&gt;cdf[j] is one cell, whereas c is a vector with 10,000 elements, which is why you are getting an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't understand what "count" &amp;nbsp;you want. &amp;nbsp;I suggest you set NSim=5 and L=8 so you can print out &amp;nbsp;x and other matrices and &amp;nbsp;tell &amp;nbsp;us what you are looking for:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* generate NSim trials of L rolls */
NSim = 5;
L = 8;
...
print x;

/* count of what? */
c1 = (x=k)[+,]; &amp;nbsp;/* number of times for each column that K appeared */
c2 = (x=k)[,+]; &amp;nbsp;/* number of times for each row that K appeared */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2017 22:55:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/enter-numbers-into-a-matrix-in-a-do-loop-specific-example/m-p/329984#M3248</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-02-04T22:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: enter numbers into a matrix in a do loop - specific example</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/enter-numbers-into-a-matrix-in-a-do-loop-specific-example/m-p/329986#M3249</link>
      <description>&lt;P&gt;Hi Rick (I knew you would reply!)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By count I mean simply the total number of trials for which all 6 faces appear in 6 rolls, in 7 rolls, 8 rolls etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know that I can multiply each cdf by 10000 and then calculate the difference between consecutive cdf's, but I just wanted to see how to do it with the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2017 23:08:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/enter-numbers-into-a-matrix-in-a-do-loop-specific-example/m-p/329986#M3249</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2017-02-04T23:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: enter numbers into a matrix in a do loop - specific example</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/enter-numbers-into-a-matrix-in-a-do-loop-specific-example/m-p/329987#M3250</link>
      <description>&lt;P&gt;The notation&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(c=K)&lt;/P&gt;
&lt;P&gt;creates a 0/1 matrix &amp;nbsp;which has the value 1 in cells for which c[i,j]=K.&lt;/P&gt;
&lt;P&gt;The notation&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(c=K)[:]&lt;/P&gt;
&lt;P&gt;takes the mean of those numbers by using &lt;A href="http://blogs.sas.com/content/iml/2011/06/06/use-subscript-reduction-operators.html" target="_self"&gt;a subscript reduction operator.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If you want the sum instead of the mean, just use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(c=K)[+]&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;sum(c=K)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cdf = j(L,1,0); /** allocate **/
do j = K to L;
   c = countunique(x[,1:j], "row");
   cdf[j] = (c=K)[+];
end;
call scatter(K:L, cdf);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2017 23:59:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/enter-numbers-into-a-matrix-in-a-do-loop-specific-example/m-p/329987#M3250</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-02-04T23:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: enter numbers into a matrix in a do loop - specific example</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/enter-numbers-into-a-matrix-in-a-do-loop-specific-example/m-p/329988#M3251</link>
      <description>&lt;P&gt;thanks! that is what I meant, but couldn't get because I just didn't know about the code&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;c&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;K&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;A small side note, this code gets the cummulative count, which is the cummulative distribution multiplied by the sample size. Is it also possible to get the discrete count, like the pdf times the sample size?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2017 00:10:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/enter-numbers-into-a-matrix-in-a-do-loop-specific-example/m-p/329988#M3251</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2017-02-05T00:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: enter numbers into a matrix in a do loop - specific example</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/enter-numbers-into-a-matrix-in-a-do-loop-specific-example/m-p/330021#M3252</link>
      <description>&lt;P&gt;The pdf is the difference between adjacent values of the cdf. Therfore&amp;nbsp;you can use the DIF function to compute the pdf from the cdf. Something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;pdf = dif(cdf);&lt;/P&gt;
&lt;P&gt;pdf[1] = 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2017 11:44:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/enter-numbers-into-a-matrix-in-a-do-loop-specific-example/m-p/330021#M3252</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-02-05T11:44:22Z</dc:date>
    </item>
  </channel>
</rss>

