<?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: probability estimation and trapezoidal rule in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/probability-estimation-and-trapezoidal-rule/m-p/151331#M1371</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As Ian notes, when dealing with a matrix language it is essential to always know the dimensions of your vectors and matrices. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a good exercise. Your professor has constructed two classic problems.&amp;nbsp; For the Monte Carlo problem, look carefully at the statement&lt;/P&gt;&lt;P&gt;y = y + (f(x)&amp;lt;1));&lt;/P&gt;&lt;P&gt;Has y been defined? If not, you cannot use it on the right hand side of an expression.&lt;/P&gt;&lt;P&gt;Good luck! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 May 2014 10:06:42 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2014-05-09T10:06:42Z</dc:date>
    <item>
      <title>probability estimation and trapezoidal rule</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/probability-estimation-and-trapezoidal-rule/m-p/151329#M1369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE style="margin: 0 0 10px; padding: 5px; font-size: 14px; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; color: #000000;"&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc iml;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call randseed(4545); * initialize the stream (like streaminit);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = J(5000,1,.); * pre-allocate space for random numbers;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call randgen(x,'normal',0,1); * fill x with N(0,1) deviates;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = y + (x**2 - 3*x**3 + 5x &amp;lt; 1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; p = y / 5000;&amp;nbsp; * MEAN acts on each matrix column;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; se = sqrt(y*(1-y)/5000); * VAR, but not STD or STDERR, also acts on columns;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "IML STEP: estimated mean of sqrt(abs(X)) is" p &lt;SPAN style="background-color: #ffffff; font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; line-height: 1.5em;"&gt;"with standard error" se;&amp;nbsp; * use PRINT, not PUT;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P style="margin: 0 0 1em; font-size: 14px; background-color: #ffffff; color: #000000; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;"&gt;I'm trying to use monte carlo integration with proc iml to estimate the probability that x**2 - 3*x**3 + 5x is less than 1. What am I doing wrong? Do loops are not allowed by the way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start tr(x,y); * create function called tr;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* handle bad case */&lt;/P&gt;&lt;P&gt;&amp;nbsp; /*if x&amp;lt;0 then do; return (.); end; * send back missing;*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; N = nrow(x);&lt;/P&gt;&lt;P&gt;&amp;nbsp; dx = x[2:N] - x[1:N-1];&lt;/P&gt;&lt;P&gt;&amp;nbsp; ymean = (y[2:N] + y[1:N-1]) / 2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; return(dx` * ymean );&lt;/P&gt;&lt;P&gt;finish tr;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x = do(-2,5,0.01);&lt;/P&gt;&lt;P&gt;print "Integral of y over x is" ( tr(x,sin(x##2)) );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; background-color: #ffffff;"&gt;I keep receiving the (execution) invalid subscript or subscript out of range. How do I solve this problem?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 May 2014 05:05:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/probability-estimation-and-trapezoidal-rule/m-p/151329#M1369</guid>
      <dc:creator>garfieldmadness</dc:creator>
      <dc:date>2014-05-09T05:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: probability estimation and trapezoidal rule</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/probability-estimation-and-trapezoidal-rule/m-p/151330#M1370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I will take the second problem.&amp;nbsp;&amp;nbsp; Insert a "print N;" statement into the module tr, I suspect the value of N is not what you think it is.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 May 2014 07:15:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/probability-estimation-and-trapezoidal-rule/m-p/151330#M1370</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2014-05-09T07:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: probability estimation and trapezoidal rule</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/probability-estimation-and-trapezoidal-rule/m-p/151331#M1371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As Ian notes, when dealing with a matrix language it is essential to always know the dimensions of your vectors and matrices. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a good exercise. Your professor has constructed two classic problems.&amp;nbsp; For the Monte Carlo problem, look carefully at the statement&lt;/P&gt;&lt;P&gt;y = y + (f(x)&amp;lt;1));&lt;/P&gt;&lt;P&gt;Has y been defined? If not, you cannot use it on the right hand side of an expression.&lt;/P&gt;&lt;P&gt;Good luck! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 May 2014 10:06:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/probability-estimation-and-trapezoidal-rule/m-p/151331#M1371</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2014-05-09T10:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: probability estimation and trapezoidal rule</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/probability-estimation-and-trapezoidal-rule/m-p/151332#M1372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should also look up the difference between the ** operator and the ## operator. Here is the doc:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/imlug/66845/HTML/default/viewer.htm#imlug_langref_sect025.htm" title="http://support.sas.com/documentation/cdl/en/imlug/66845/HTML/default/viewer.htm#imlug_langref_sect025.htm"&gt;SAS/IML(R) 13.1 User's Guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 May 2014 12:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/probability-estimation-and-trapezoidal-rule/m-p/151332#M1372</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2014-05-09T12:48:43Z</dc:date>
    </item>
  </channel>
</rss>

