<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246881</link>
    <title>MATLAB Central Newsreader - simple integration of joint normal - TPT doesn't work</title>
    <description>Feed for thread: simple integration of joint normal - TPT doesn't work</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 17 Mar 2009 18:04:01 -0400</pubDate>
      <title>simple integration of joint normal - TPT doesn't work</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246881#635595</link>
      <author>Pete sherer</author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
This problem seems to be simple and should have any problem when coding.  However, it seems to create problems on my side.  Below, I am trying to obtain a marginal distribution from a joint lognormal distribution.  I howver can't get the same answer as the theoretical one when correlation is different from zero.&lt;br&gt;
&lt;br&gt;
levSde2Exc  = 1; &lt;br&gt;
trho        = 0.0;&lt;br&gt;
[ meanSde1, meanSde2 ] = deal( log(1), log(2));&lt;br&gt;
[ var1, var2] = deal( (0.6), (0.8));&lt;br&gt;
&lt;br&gt;
% define integration range over the first variable (i.e., Sde_1)&lt;br&gt;
min1 = meanSde1 - 5*sqrt(var1); % min( log(Sde_1levIM));&lt;br&gt;
max1 = meanSde1 + 5*sqrt(var1); % max( log(Sde_1levIM));&lt;br&gt;
&lt;br&gt;
Sde_1levIM = exp( linspace( min1, max1, 3000) );&lt;br&gt;
numSdeT1 = length( Sde_1levIM);&lt;br&gt;
fsde2_condSde1 = zeros( 1, numSdeT1);&lt;br&gt;
&lt;br&gt;
% using the Total probability Theorem to integrate jointly lognormal distribution to obtain the marginal of the 2nd variable (i.e., Sde_2)&lt;br&gt;
fxdx     = normpdf( log( Sde_1levIM), meanSde1, sqrt( var1));&lt;br&gt;
fxdx     = fxdx./ sum( fxdx);&lt;br&gt;
for runSde1 = 1: numSdeT1 % I can collapse this for loop&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;levSde1          = Sde_1levIM( 1, runSde1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mean_22Cond = meanSde2 + sqrt( var2)/sqrt(var1)*trho*( levSde1 - meanSde1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var_22Cond  = (1-trho^2)* var2;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tpSde2_condX_Sde1          = normpdf( log( levSde2Exc), mean_22Cond, sqrt( var_22Cond)); &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fsde2_condSde1( 1, runSde1) = tpSde2_condX_Sde1.* fxdx( 1, runSde1);  &lt;br&gt;
end %     for runSde1 = 1: length(scalarPSHA.Sde_1.levIM)&lt;br&gt;
&lt;br&gt;
%% Integrated fsde2&lt;br&gt;
fsde2_cal = sum( fsde2_condSde1, 2);&lt;br&gt;
%% Marginal fsde2&lt;br&gt;
fsde2_theo = normpdf( log( levSde2Exc), meanSde2, sqrt( var2) );&lt;br&gt;
&lt;br&gt;
when correlation (trho = 0), I get the same answer between fsde2_cal and fsde2_theo  which is 0.3303.&lt;br&gt;
&lt;br&gt;
when trho = 0.5, fsde2_cal = 0.1342 which is different from 0.3303.&lt;br&gt;
&lt;br&gt;
Any suggestions to this simple problem.  Thank you so much in advance.</description>
    </item>
    <item>
      <pubDate>Tue, 17 Mar 2009 18:20:17 -0400</pubDate>
      <title>Re: simple integration of joint normal - TPT doesn't work</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246881#635601</link>
      <author>Pete sherer</author>
      <description>found the BUG!!&lt;br&gt;
I forgot to take log of levSde1 when calculating mean_22Cond.&lt;br&gt;
&lt;br&gt;
it should read&lt;br&gt;
mean_22Cond = meanSde2 + sqrt( var2)/sqrt(var1)*trho*( log(levSde1) - meanSde1)</description>
    </item>
  </channel>
</rss>

