<?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: Generating exponential and gamma distribution in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215445#M2239</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Xia. I will try and see what I get&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 02 Aug 2015 04:52:11 GMT</pubDate>
    <dc:creator>SWEETSAS</dc:creator>
    <dc:date>2015-08-02T04:52:11Z</dc:date>
    <item>
      <title>Generating exponential and gamma distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215439#M2233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I observe there are different SAS statement to generate exponential and gamma distribution. This is what I have used.&lt;/P&gt;&lt;P&gt;seed=2345;&lt;/P&gt;&lt;P&gt;theta=0.5; *scale parameter; &lt;/P&gt;&lt;P&gt;V=theta*ranexp(seed);&lt;/P&gt;&lt;P&gt;W=2*rangam(seed,theta)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These are not giving me what I want when I try to estimate the parameters of the generated distribution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the distribution I am trying to generate:&lt;/P&gt;&lt;P class="page" title="Page 1"&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMMI10;"&gt;V&lt;/SPAN&gt;&lt;SPAN style="font-size: 7pt; font-family: CMMI7;"&gt;i &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMSY10;"&gt;∼ &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMMI10;"&gt;Exponential&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMR10;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMMI10;"&gt;θ&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMR10;"&gt;);&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMMI10;"&gt;i &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMR10;"&gt;= 1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMMI10;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMR10;"&gt;2&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMMI10;"&gt;,...n &lt;/SPAN&gt; &lt;/P&gt;&lt;P class="page" title="Page 1"&gt;&lt;SPAN style="font-size: 10pt; font-family: CMMI10;"&gt;W&lt;/SPAN&gt;&lt;SPAN style="font-size: 7pt; font-family: CMMI7;"&gt;i &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMSY10;"&gt;∼ &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMMI10;"&gt;Gamma&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMR10;"&gt;(2&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMMI10;"&gt;,θ&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMR10;"&gt;);&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMMI10;"&gt;i &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMR10;"&gt;= 1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMMI10;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMR10;"&gt;2&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: CMMI10;"&gt;,...n &lt;/SPAN&gt; &lt;/P&gt;&lt;P class="page" title="Page 1"&gt;To be sure that my generation is okay, I want to estimate the parameters of the generated distribution to see how close it is to the value I use in generating the distribution. &lt;/P&gt;&lt;P class="page" title="Page 1"&gt;&lt;/P&gt;&lt;P class="page" title="Page 1"&gt;&lt;/P&gt;&lt;P class="page" title="Page 1"&gt;&lt;/P&gt;&lt;P class="page" title="Page 1"&gt;Thanks in advance&lt;/P&gt;&lt;P class="page" title="Page 1"&gt;&lt;/P&gt;&lt;P class="page" title="Page 1"&gt;Jack&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Aug 2015 00:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215439#M2233</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2015-08-02T00:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Generating exponential and gamma distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215440#M2234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Proc Univariate will generate distributions parameters&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#procstat_univariate_sect077.htm" style="font-size: 10pt; line-height: 1.5em;" title="http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#procstat_univariate_sect077.htm"&gt;Base SAS(R) 9.2 Procedures Guide: Statistical Procedures, Third Edition&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Aug 2015 03:39:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215440#M2234</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-08-02T03:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: Generating exponential and gamma distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215441#M2235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;RANDGEN() can't get it ?&lt;/P&gt;&lt;P&gt;call randgen(x, 'EXPO'); &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want estimate distribution's parameter , check the following link by Rick , how to get the best parameter by Maximizing Likelihood Function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2011/10/12/maximum-likelihood-estimation-in-sasiml.html" title="http://blogs.sas.com/content/iml/2011/10/12/maximum-likelihood-estimation-in-sasiml.html"&gt;http://blogs.sas.com/content/iml/2011/10/12/maximum-likelihood-estimation-in-sasiml.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Aug 2015 04:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215441#M2235</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-08-02T04:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Generating exponential and gamma distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215442#M2236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Reeza.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used this univariate procedure earlier, but the parameter estimates that I obtained are far from what I used in simulation. Perhaps, I am not simulating the data correctly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Aug 2015 04:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215442#M2236</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2015-08-02T04:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Generating exponential and gamma distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215443#M2237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. What's the difference between randgen and randexp? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Aug 2015 04:19:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215443#M2237</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2015-08-02T04:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Generating exponential and gamma distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215444#M2238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;According to @Rick , It is obsolete function which couldn't generate real random number ,and it is deprecated in Documentation.&lt;/P&gt;&lt;P&gt;However RANDGEN() does , Therefore, always use RANDGEN() to generate any sort of distribution , NOT randXXX() .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Aug 2015 04:27:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215444#M2238</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-08-02T04:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Generating exponential and gamma distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215445#M2239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Xia. I will try and see what I get&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Aug 2015 04:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215445#M2239</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2015-08-02T04:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: Generating exponential and gamma distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215446#M2240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I assume you want the solution in IML? There are many parameterization of distribution functions, but it sounds like you want&lt;/P&gt;&lt;P&gt;1) Expoentiatl with scale parameter sigma=0.5&lt;/P&gt;&lt;P&gt;2) Gamma with shape parameter alpha=2 and shape parameter sigma=0.5;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For both situations&amp;nbsp; you can allocate a vector (or matrix) and fill it up by &lt;A href="http://support.sas.com/documentation/cdl/en/imlug/68150/HTML/default/viewer.htm#imlug_langref_sect339.htm"&gt;calling the RANDGEN subroutine&lt;/A&gt;. The following generates vectors with 1,000 variates.&amp;nbsp; The program then writes the simulated data to a data set and call PROC UNIVARIATE to verify that the MLE estimates are close to the specified values:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;BR /&gt;call randseed(1);&lt;/P&gt;&lt;P&gt;sigma = 0.5; /* scale parameter */&lt;BR /&gt;E = j(1000, 1);&lt;BR /&gt;call randgen(E, "Exponential", sigma); /* E ~ Expo(0.5) */&lt;BR /&gt;G = j(1000, 1);&lt;BR /&gt;call randgen(G, "Gamma", 2, sigma); /* G ~ Gamma(2, 0.5) */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create test var {E G}; append; close;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc univariate data=test;&lt;BR /&gt;histogram E / exponential(scale=EST) endpoints=(0 to 5 by 0.25);&lt;BR /&gt;histogram G / gamma(shape=EST scale=EST) endpoints=(0 to 5 by 0.25);&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Aug 2015 11:05:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215446#M2240</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-08-02T11:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Generating exponential and gamma distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215447#M2241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The numbers from RANDGEN are not "real" either. Both algorithms generate pseudo-random numbers. It is just that the algorithm that RANDGEN uses is more sophisticated.&amp;nbsp; For details, see&lt;/P&gt;&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2013/07/10/stop-using-ranuni.html"&gt;"Six reasons you should stop using the RANUNI function to generate random numbers"&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Aug 2015 11:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215447#M2241</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-08-02T11:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Generating exponential and gamma distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215448#M2242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks!!!! Worked like a charm!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Aug 2015 13:05:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/215448#M2242</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2015-08-02T13:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: Generating exponential and gamma distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/225054#M2287</link>
      <description>&lt;P&gt;Hi Rick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please, after reading your post I have began to learn how to IML for simulation&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following program works perfectly well; it gives me what I want. However, in data step, I can easily create sample ID &amp;nbsp;using a do "rep=1 to m" and analyze by that sample ID. By sample ID, I mean replicate. How do I generate the sample ID (replicate) in IML so that I can analyze my data by sample ID?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc iml;&lt;BR /&gt;call randseed(1);&lt;/P&gt;
&lt;P&gt;sigma = 0.5; /* scale parameter */&lt;BR /&gt;E = j(1000, 1);&lt;BR /&gt;call randgen(E, "Exponential", sigma); /* E ~ Expo(0.5) */&lt;BR /&gt;G = j(1000, 1);&lt;BR /&gt;call randgen(G, "Gamma", 2, sigma); /* G ~ Gamma(2, 0.5) */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;create test var {E G}; append; close;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc univariate data=test;&lt;BR /&gt;histogram E / exponential(scale=EST) endpoints=(0 to 5 by 0.25);&lt;BR /&gt;histogram G / gamma(shape=EST scale=EST) endpoints=(0 to 5 by 0.25);&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 01:33:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/225054#M2287</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2015-09-11T01:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Generating exponential and gamma distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/225073#M2288</link>
      <description>&lt;P&gt;There are probably&amp;nbsp;lots of ways of solving this.&amp;nbsp; Your data step solution could be made to work in IML too, as you could write a loop&amp;nbsp;and then APPEND inside, each time adding records with the loop variable and a single&amp;nbsp;random number.&amp;nbsp; But if you want to retain the efficiency of Rick's code that generates a vector of random numbers all at once, then you will need to&amp;nbsp;create&amp;nbsp;vectors the same length, that contain the required ID information.&amp;nbsp; I like to use the direct product operator '@'&amp;nbsp;for this as follows (assuming you want to generate 10 reps for each of 100 IDs):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
call randseed(1);

sigma = 0.5; /* scale parameter */
E = j(1000, 1);
call randgen(E, "Exponential", sigma); /* E ~ Expo(0.5) */
G = j(1000, 1);
call randgen(G, "Gamma", 2, sigma); /* G ~ Gamma(2, 0.5) */

ID = t(1:100) @ j(10,1);
REP = j(100,1) @ t(1:10);

create test var {ID REP E G}; append; close;

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Sep 2015 07:36:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/225073#M2288</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2015-09-11T07:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: Generating exponential and gamma distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/225148#M2289</link>
      <description>&lt;P&gt;If you have my book &lt;EM&gt;Simulating Data with SAS&lt;/EM&gt;, you can read about this on p. 69 and throughout the book.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ian is a whiz with the Kronecker direct product (@). I am less proficient, so I tend to use the REPEAT function. You can read about my approach in the article &lt;A href="http://blogs.sas.com/content/iml/2012/06/27/create-an-id-vector-for-repeated-measurements.html" target="_self"&gt;"Create an ID vector for repeated measurements."&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS. Please address your questions to the list, not to me personally. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 12:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-exponential-and-gamma-distribution/m-p/225148#M2289</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-09-11T12:45:28Z</dc:date>
    </item>
  </channel>
</rss>

