<?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: Binomial and Poisson distribution in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Binomial-and-Poisson-distribution/m-p/162669#M1552</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In SAS/IML there are essentially two ways.&amp;nbsp; The random sample can be generated one at a time with the usual Base SAS functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call streaminit(1234);&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i = 1 to 10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = rand('binomial', 0.05, 20);&amp;nbsp; /* p=0.05&amp;nbsp; n=20 */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; p = rand('poisson', 5);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* lambda=5 */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print b p;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However the RANDGEN call is usually the best option.&amp;nbsp; In general it is more efficient not to use a loop and generate the random numbers all at the same time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; b = j(10, 1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; p = j(10, 1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; call randseed(4321);&lt;/P&gt;&lt;P&gt;&amp;nbsp; call randgen(b, 'binomial', 0.05, 20);&lt;/P&gt;&lt;P&gt;&amp;nbsp; call randgen(p, 'poisson', 5);&lt;/P&gt;&lt;P&gt;&amp;nbsp; print b p;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 09 Nov 2014 10:09:19 GMT</pubDate>
    <dc:creator>IanWakeling</dc:creator>
    <dc:date>2014-11-09T10:09:19Z</dc:date>
    <item>
      <title>Binomial and Poisson distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Binomial-and-Poisson-distribution/m-p/162668#M1551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I want to generate a random sample from Binomial distribution (it will be included inside a loop) and another one from Poisson distribution.&lt;/P&gt;&lt;P&gt;How can I do this?&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Nov 2014 18:48:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Binomial-and-Poisson-distribution/m-p/162668#M1551</guid>
      <dc:creator>maureen</dc:creator>
      <dc:date>2014-11-08T18:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: Binomial and Poisson distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Binomial-and-Poisson-distribution/m-p/162669#M1552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In SAS/IML there are essentially two ways.&amp;nbsp; The random sample can be generated one at a time with the usual Base SAS functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call streaminit(1234);&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i = 1 to 10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = rand('binomial', 0.05, 20);&amp;nbsp; /* p=0.05&amp;nbsp; n=20 */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; p = rand('poisson', 5);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* lambda=5 */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print b p;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However the RANDGEN call is usually the best option.&amp;nbsp; In general it is more efficient not to use a loop and generate the random numbers all at the same time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; b = j(10, 1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; p = j(10, 1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; call randseed(4321);&lt;/P&gt;&lt;P&gt;&amp;nbsp; call randgen(b, 'binomial', 0.05, 20);&lt;/P&gt;&lt;P&gt;&amp;nbsp; call randgen(p, 'poisson', 5);&lt;/P&gt;&lt;P&gt;&amp;nbsp; print b p;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Nov 2014 10:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Binomial-and-Poisson-distribution/m-p/162669#M1552</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2014-11-09T10:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Binomial and Poisson distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Binomial-and-Poisson-distribution/m-p/162670#M1553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ian's answer is correct. I will add that if you are only going to simulate ONE sample (that is, not inside a loop), you can use the newer RANDFUN function in SAS/IML 12.3: &lt;A href="http://blogs.sas.com/content/iml/2014/06/16/rand-functions-vs-subroutines/" title="http://blogs.sas.com/content/iml/2014/06/16/rand-functions-vs-subroutines/"&gt; Convenient functions vs. efficient subroutines: Your choice - The DO Loop&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you mention the binomial and Poisson distribution together, I wonder whether you are forming a compound distribution? If so, see this article: &lt;A href="http://blogs.sas.com/content/iml/2014/04/02/interpret-nb-distribution/" title="http://blogs.sas.com/content/iml/2014/04/02/interpret-nb-distribution/"&gt; A different way to interpret the negative binomial distribution - The DO Loop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Nov 2014 11:53:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Binomial-and-Poisson-distribution/m-p/162670#M1553</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2014-11-09T11:53:39Z</dc:date>
    </item>
  </channel>
</rss>

