<?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: Truncated distribution generation in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Truncated-distribution-generation/m-p/244402#M2544</link>
    <description>Thanks PGstat. The code works for univariate case</description>
    <pubDate>Tue, 19 Jan 2016 11:22:48 GMT</pubDate>
    <dc:creator>SWEETSAS</dc:creator>
    <dc:date>2016-01-19T11:22:48Z</dc:date>
    <item>
      <title>Truncated distribution generation</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Truncated-distribution-generation/m-p/244322#M2540</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Expert does any one now what is wrong with the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am simulating a &amp;nbsp;truncated distribution &amp;nbsp;that is multivariate in nature with the follow code from Rick's blog, but it not working well:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data TruncNormal(keep=x fa fb);&lt;BR /&gt;Fa = cdf('Normal', 30); /* for a = 30 */&lt;BR /&gt;Fb = cdf('Normal', 50); /* for b = 50 */&lt;BR /&gt;call streaminit(1234);&lt;BR /&gt;do i = 1 to 1000; /* sample size = 1000 */ &lt;BR /&gt; v = Fa + (Fb-Fa)*rand('Uniform'); /* V ~ U(F(a), F(b)) */&lt;BR /&gt; x = quantile('Normal', v); /* truncated normal on [a,b] */&lt;BR /&gt; output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt; &lt;BR /&gt;ods select histogram;&lt;BR /&gt;proc univariate data=TruncNormal;&lt;BR /&gt; histogram x / endpoints=30 to 50 by 5;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The aim is to simulate a truncated &amp;nbsp;[a=30,b=50] distribution that is normally distribution. Minimum value is 30 maximum value is 50. The orginal normal distribution has a mean of 38 and standard of 5. Following generation,I like to check to see that the generated distribution is in fact a PDF.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above case is aimed to generate on one instance of such a truncated distribution, but I want to genereate three of such variable so that I have a multivariate distrunction &amp;nbsp;with column=3 and a with specified covariance. The plan is to generate the truncated distribution thrice and then merge but that can't build the covariance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see that one can still use acceptance-rejection, but building covariance/correlation may be challenging.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 23:58:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Truncated-distribution-generation/m-p/244322#M2540</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2016-01-18T23:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: Truncated distribution generation</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Truncated-distribution-generation/m-p/244344#M2541</link>
      <description>&lt;P&gt;You must specify the parameters of the simulated truncated distribution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TruncNormal(keep=x fa fb);
Fa = cdf('Normal', 30, 38, 5); /* for a = 30 */
Fb = cdf('Normal', 50, 38, 5); /* for b = 50 */
call streaminit(1234);
do i = 1 to 1000; /* sample size = 1000 */ 
    v = Fa + (Fb-Fa)*rand('Uniform'); /* V ~ U(F(a), F(b)) */
    x = quantile('Normal', v, 38, 5); /* truncated normal on [a,b] */
    output;
    end;
run;

ods select histogram;
proc univariate data=TruncNormal;
histogram x / endpoints=28 to 52 by 2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Jan 2016 03:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Truncated-distribution-generation/m-p/244344#M2541</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-01-19T03:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: Truncated distribution generation</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Truncated-distribution-generation/m-p/244395#M2542</link>
      <description>&lt;P&gt;Apparently the reference is &lt;A href="http://blogs.sas.com/content/iml/2013/07/22/the-inverse-cdf-method.html" target="_self"&gt;"The inverse CDF method for simulating from a distribution,"&lt;/A&gt;&amp;nbsp;which is based on Chapter 7 of &lt;EM&gt;Simulating Data with SAS &lt;/EM&gt;(Wicklin 2013)..&lt;/P&gt;
&lt;P&gt;See also &lt;A href="http://blogs.sas.com/content/iml/2013/07/24/the-truncated-normal-in-sas.html" target="_self"&gt;"Implement the truncated normal distribution in SAS."&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your eventual goal is multivariate correlated, I recommend reading Chapter 9, "Advanced Simulation of Multivariate Data"&amp;nbsp;as well as searching the literature.&amp;nbsp;This looks like a challenging problem!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2016 10:59:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Truncated-distribution-generation/m-p/244395#M2542</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-01-19T10:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Truncated distribution generation</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Truncated-distribution-generation/m-p/244401#M2543</link>
      <description>Thanks. Yes, multivariate correlated is the goal. And yes, it is a challenging problem.</description>
      <pubDate>Tue, 19 Jan 2016 11:21:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Truncated-distribution-generation/m-p/244401#M2543</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2016-01-19T11:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Truncated distribution generation</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Truncated-distribution-generation/m-p/244402#M2544</link>
      <description>Thanks PGstat. The code works for univariate case</description>
      <pubDate>Tue, 19 Jan 2016 11:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Truncated-distribution-generation/m-p/244402#M2544</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2016-01-19T11:22:48Z</dc:date>
    </item>
  </channel>
</rss>

