<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264578</link>
    <title>MATLAB Central Newsreader - Exp function question</title>
    <description>Feed for thread: Exp function question</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>Wed, 04 Nov 2009 20:08:02 -0500</pubDate>
      <title>Re: Exp function question</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264578#692179</link>
      <author>Sebastian Arslanogullari</author>
      <description>Hi Deb&lt;br&gt;
Could you be a bit more specific on what exactly you are trying to do? Generating the series the way you do (i.e. by taking exp of a normally distributed variable) will give you a lognormally distributed variable. I.e. z in the final row of your code will be lognormally distributed and have an expected value of exp(my+1/2sigma^2). Is this what you are trying to accomplish?&lt;br&gt;
&lt;br&gt;
I'm just guessing but are you trying to generate asset paths (i.e. a geometric brownian motion model)?&lt;br&gt;
Regards&lt;br&gt;
/Sebastian Arslanogullari&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Deb &quot; &amp;lt;jackbr20@gmail.com&amp;gt; wrote in message &amp;lt;hcf5a6$gjg$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I need to generate values for variable z (n=100). The variable should be generated using X=mu(X)+error term where mu(z) is mean of z series and error term is drawing from a standard normal distribution with mean 0 and variance equal to 1.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Values should be generated in log form to avoid the possibility of obtaining zero or negative values : z=mu(ln Z)+e where mu(z ln) is mean of natural log of z series. After the series is generated the data should be exponentiated to obtain levels (i.e. z=e^ln z).&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I've tried to create the z series by using this script:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; n=100;&lt;br&gt;
&amp;gt; mean=0;&lt;br&gt;
&amp;gt; sd=1;&lt;br&gt;
&amp;gt; z1=log(mean+sd);       % log form of Z series&lt;br&gt;
&amp;gt; z2=normrnd(0,1,n,1);  % error term with mean 0 and variance 1                   &lt;br&gt;
&amp;gt; z=exp(z1+z2);             % exponentiate data&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Do you think that the code is in line with the description? I'm not sure if exponentiating is done correctly by simply using the exp function.</description>
    </item>
    <item>
      <pubDate>Wed, 04 Nov 2009 20:16:51 -0500</pubDate>
      <title>Re: Exp function question</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264578#692182</link>
      <author>TideMan</author>
      <description>On Oct 31, 5:47&#160;am, &quot;Deb &quot; &amp;lt;jackb...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; I need to generate values for variable z (n=100). The variable should be generated using X=mu(X)+error term where mu(z) is mean of z series and error term is drawing from a standard normal distribution with mean 0 and variance equal to 1.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Values should be generated in log form to avoid the possibility of obtaining zero or negative values : z=mu(ln Z)+e where mu(z ln) is mean of natural log of z series. After the series is generated the data should be exponentiated to obtain levels (i.e. z=e^ln z).&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I've tried to create the z series by using this script:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; n=100;&lt;br&gt;
&amp;gt; mean=0;&lt;br&gt;
&amp;gt; sd=1;&lt;br&gt;
&amp;gt; z1=log(mean+sd); &#160; &#160; &#160; % log form of Z series&lt;br&gt;
&amp;gt; z2=normrnd(0,1,n,1); &#160;% error term with mean 0 and variance 1 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&lt;br&gt;
&amp;gt; z=exp(z1+z2); &#160; &#160; &#160; &#160; &#160; &#160; % exponentiate data&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Do you think that the code is in line with the description? I'm not sure if exponentiating is done correctly by simply using the exp function.&lt;br&gt;
&lt;br&gt;
It's YOUR homework.&lt;br&gt;
Why are you asking us?</description>
    </item>
    <item>
      <pubDate>Sat, 07 Nov 2009 07:21:24 -0500</pubDate>
      <title>Re: Exp function question</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264578#692851</link>
      <author>Deb </author>
      <description>Hi Sebastian and thank you for your reply. I'm just trying to generate values that can only have positive values. I understand that lognormal variable is always positive but I'm not sure why in the literature there is examples saying that the generated series should be exponentiated in order to get levels (what does it mean &quot;to get levels&quot;?).&lt;br&gt;
&lt;br&gt;
Deb&lt;br&gt;
&lt;br&gt;
PS. TideMan: Knowledge is power, but it a sign of wisdom to share it with others.</description>
    </item>
    <item>
      <pubDate>Sun, 08 Nov 2009 19:51:01 -0500</pubDate>
      <title>Re: Exp function question</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264578#693063</link>
      <author>Sebastian Arslanogullari</author>
      <description>What the literature is saying is that if you generate a random vector of normally distributed variables and take the exp, you will receive a vector of lognormally distributed variables.&lt;br&gt;
The mean will be as I wrote in my answer, i.e. if you want the mean of the lognormally distributed values to be my, you should subtract 1/2sigma^2 before taking exp, e.g.&lt;br&gt;
x = log(2)+randn(10000,1);   % Normal with mean 2 and variance 1&lt;br&gt;
xpos = exp(x-0.5);   % lognormal with mean 2&lt;br&gt;
&lt;br&gt;
Regards&lt;br&gt;
Sebastian&lt;br&gt;
&lt;br&gt;
&quot;Deb &quot; &amp;lt;jackbr20@gmail.com&amp;gt; wrote in message &amp;lt;hd375k$bem$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi Sebastian and thank you for your reply. I'm just trying to generate values that can only have positive values. I understand that lognormal variable is always positive but I'm not sure why in the literature there is examples saying that the generated series should be exponentiated in order to get levels (what does it mean &quot;to get levels&quot;?).&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Deb&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; PS. TideMan: Knowledge is power, but it a sign of wisdom to share it with others.</description>
    </item>
    <item>
      <pubDate>Sun, 08 Nov 2009 20:39:27 -0500</pubDate>
      <title>Re: Exp function question</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264578#693072</link>
      <author>TideMan</author>
      <description>On Nov 7, 8:21&#160;pm, &quot;Deb &quot; &amp;lt;jackb...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hi Sebastian and thank you for your reply. I'm just trying to generate values that can only have positive values. I understand that lognormal variable is always positive but I'm not sure why in the literature there is examples saying that the generated series should be exponentiated in order to get levels (what does it mean &quot;to get levels&quot;?).&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Deb&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; PS. TideMan: Knowledge is power, but it a sign of wisdom to share it with others.&lt;br&gt;
&lt;br&gt;
Well, here's another maxim (I'll take the credit for it):&lt;br&gt;
She who does her own homework gains more than she would by getting&lt;br&gt;
others to do it for her.</description>
    </item>
  </channel>
</rss>

