{"id":5524,"date":"2023-02-15T14:48:32","date_gmt":"2023-02-15T06:48:32","guid":{"rendered":"https:\/\/fanyuzhao.com\/?p=5524"},"modified":"2023-02-15T14:50:36","modified_gmt":"2023-02-15T06:50:36","slug":"taylor-series-and-transition-density-functions","status":"publish","type":"post","link":"https:\/\/fanyuzhao.com\/?p=5524","title":{"rendered":"Taylor Series and Transition Density Functions"},"content":{"rendered":"\n<p>See my Github repo for full details.<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/eightsmile\/cqf\">https:\/\/github.com\/eightsmile\/cqf<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Trinomial Random Walk<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">2. Transition Probability Density Function<\/h2>\n\n\n\n<p>The transition probability density function, <span class=\"katex math inline\">p(y,t;y&#8217;,t&#8217;)<\/span>, is defined by,<\/p>\n\n\n\n<p>$$ Prob(a&lt;y'&lt;b, at\\ time \\ t&#8217; | y \\ at \\ time\\ t) = \\int_a^b p(yet;y&#8217;,t&#8217;)dy&#8217;$$<\/p>\n\n\n\n<p>In words this is \u201cthe probability that the random variable y \u2032 lies between a and b at time t \u2032 in the future, given that it started out with value y at time t.\u201d<\/p>\n\n\n\n<p>Think of y and t as being current values with y \u2032 and t \u2032 being future values. The transition probability density function can be used to answer the question,<\/p>\n\n\n\n<p>\u201cWhat is the probability of the variable y \u2032 being in a speci\ufb01ed range at time t \u2032 in the future given that it started out with value y at time t?\u201d<\/p>\n\n\n\n<p><strong><em>Our Goal is to find the transition probability p.d.f., and so we find the relationship between <span class=\"katex math inline\">p(y,t;y&#8217;,t&#8217;)<\/span>, and <span class=\"katex math inline\">p(y,t;y&#8217;,t&#8217;-\\delta t)<\/span>,<\/em><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. From the Trinomial model to the Transition Probability Density function<\/h2>\n\n\n\n<p>The variable y can either rise, fall or take the same value after a time step \u03b4t. These <strong>movements have certain probabilities<\/strong> associated with them.<\/p>\n\n\n\n<p>We are going to assume that the probability of a rise and a fall are both the same, <span class=\"katex math inline\">\\alpha<\\frac{1}{2}<\/span> . (But, of course, this can be generalized. Why would we want to generalize this?)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3.1 The Forward Equation<\/h3>\n\n\n\n<p>Given <span class=\"katex math inline\">{y,t}<\/span>, or says <span class=\"katex math inline\">{y,t}<\/span> the current and previous. <span class=\"katex math inline\">{y&#8217;,t&#8217;}<\/span> are variate in the future time.<\/p>\n\n\n\n<p>The probability of being at <span class=\"katex math inline\">y&#8217;<\/span> at time <span class=\"katex math inline\">t&#8217;<\/span> is related to the probabilities of being at the previous three values and moving in the right direction:<\/p>\n\n\n\n<p>$$ p(y,t;y&#8217;,t&#8217;) = \\alpha \\ p(y,t;y&#8217;+\\delta y,t&#8217;-\\delta t) + \\ (1-2\\alpha) \\ p(y,t;y&#8217;,t&#8217;-\\delta t) + \\alpha \\ p(y,t;y&#8217;-\\delta y,t&#8217;-\\delta t) $$<\/p>\n\n\n\n<p><strong><em>Given <span class=\"katex math inline\">{y,t}<\/span>, we find relationship between <span class=\"katex math inline\">{y&#8217;,t&#8217;}<\/span> and <span class=\"katex math inline\">{y&#8217;\\pm \\delta y,t&#8217;-\\delta t}<\/span> that is y&#8217; and t&#8217; a bit time previously.<\/em><\/strong><\/p>\n\n\n\n<p><strong><em>Remember, our goal is to find a solution of <span class=\"katex math inline\">p(.)<\/span>, we try to solve the above equation.<\/em><\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3.2 Taylor Series Expansion<\/h3>\n\n\n\n<p>We expand each term of the <strong>equation<\/strong>.<\/p>\n\n\n\n<p>$$ p(y,t;y&#8217;,t&#8217;) = \\alpha \\ p(y,t;y&#8217;+\\delta y,t&#8217;-\\delta t) + \\ (1-2\\alpha) \\ p(y,t;y&#8217;,t&#8217;-\\delta t) + \\alpha \\ p(y,t;y&#8217;-\\delta y,t&#8217;-\\delta t) $$<\/p>\n\n\n\n<p><strong><em>Why we do that? Because there are too many variables in it, hard to solve it. We have to reduce the dimension.<\/em><\/strong><\/p>\n\n\n\n<p>$$ p(y,t;y&#8217;+\\delta y,t&#8217;-\\delta t)\\approx \\ p(y,t;y&#8217;,t) &#8211; \\delta t \\frac{\\partial p}{\\partial t&#8217;} +\\delta y \\frac{\\partial p}{\\partial y&#8217;} + \\frac{1}{2}\\delta y^2 \\frac{\\partial^2 p}{\\partial y&#8217;^2} + O(\\frac{\\partial^2 p}{\\partial t&#8217;^2}) $$<\/p>\n\n\n\n<p>$$ p(y,t;y&#8217;,t&#8217;-\\delta t)\\approx \\ p(y,t;y&#8217;,t) &#8211; \\delta t \\frac{\\partial p}{\\partial t&#8217;} + O(\\frac{\\partial^2 p}{\\partial t&#8217;^2}) $$<\/p>\n\n\n\n<p>$$ p(y,t;y&#8217;-\\delta y,t&#8217;-\\delta t)\\approx \\ p(y,t;y&#8217;,t) &#8211; \\delta t \\frac{\\partial p}{\\partial t&#8217;} -\\delta y \\frac{\\partial p}{\\partial y&#8217;} + \\frac{1}{2}\\delta y^2 \\frac{\\partial^2 p}{\\partial y&#8217;^2} + O(\\frac{\\partial^2 p}{\\partial t&#8217;^2}) $$<\/p>\n\n\n\n<p>Plug them back into that <strong>equation<\/strong>, and after cancel out terms repeated we would left with,<\/p>\n\n\n\n<p>$$ \\frac{\\partial p}{\\partial t&#8217;} =\\alpha \\frac{\\delta y^2}{\\delta t} \\frac{\\partial^2 p}{\\partial y&#8217;^2} + O(\\frac{\\partial^2 p}{\\partial t&#8217;^2})$$<\/p>\n\n\n\n<p>We drop those derivative terms with order greater and equal than <span class=\"katex math inline\">O(\\frac{\\partial^2 p}{\\partial t&#8217;^2})<\/span>.<\/p>\n\n\n\n<p>$$ \\frac{\\partial p}{\\partial t&#8217;} =\\alpha \\frac{\\delta y^2}{\\delta t} \\frac{\\partial^2 p}{\\partial y&#8217;^2} $$<\/p>\n\n\n\n<p>In the RHS, we focus on <span class=\"katex math inline\">\\alpha \\frac{\\delta y^2}{\\delta t}<\/span>, firstly. The denominator and numerator have to be in the same order to make that term definite. Or, say <span class=\"katex math inline\">\\delta y \\sim O(\\sqrt{\\delta t})<\/span>.<\/p>\n\n\n\n<p>We thus let <span class=\"katex math inline\">c^2 = \\alpha \\frac{\\delta y^2}{\\delta t}<\/span><\/p>\n\n\n\n<p>$$ \\frac{\\partial p}{\\partial t&#8217;} =c^2 \\frac{\\partial^2 p}{\\partial y&#8217;^2} $$<\/p>\n\n\n\n<p>The above equation is also named <strong>Fokker\u2013Planck<\/strong> or <strong>forward Kolmogorov equation.<\/strong><\/p>\n\n\n\n<p><strong><em>Now, we have a partial differential equation. Solve it, we can get the form of <span class=\"katex math inline\">p<\/span>.<\/em><\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3.3 Backward Equation works similar.<\/h3>\n\n\n\n<p>$$ p(y,t;y&#8217;,t&#8217;) = \\alpha \\ p(y+\\delta y,t+\\delta t;y&#8217;,t&#8217;) + \\ (1-2\\alpha) \\ p(y,t+\\delta t;y&#8217;,t&#8217;) + \\alpha \\ p(y-\\delta y,t+\\delta t;y&#8217;,t&#8217;) $$<\/p>\n\n\n\n<p>the dimension-reduced result is the blow, and it is called the <strong>backward Kolmogorov equation<\/strong>.<\/p>\n\n\n\n<p>$$ \\frac{\\partial p}{\\partial t&#8217;} + c^2 \\frac{\\partial^2 p}{\\partial y&#8217;^2} =0 $$<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Solve the Forward Kolmogorov Equation<\/h2>\n\n\n\n<p>We will solve for <span class=\"katex math inline\">p<\/span> right now! However, we will solve it by assuming similarity solution.<\/p>\n\n\n\n<p>$$ \\frac{\\partial p}{\\partial t&#8217;} =c^2 \\frac{\\partial^2 p}{\\partial y&#8217;^2} $$<\/p>\n\n\n\n<p>This equation has an in\ufb01nite number of solutions. It has di\ufb00erent solutions for di\ufb00erent initial conditions and di\ufb00erent boundary conditions. <strong><em><u>We need only a special solution here.<\/u><\/em><\/strong> The detailed process of finding that solution is showing as the following,<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. 1 Assume a Solution Form<\/h3>\n\n\n\n<p>$$ p=t&#8217;^a f(\\frac{y&#8217;}{t&#8217;^b}) = t&#8217;^a f(\\xi)$$<\/p>\n\n\n\n<p>$$ \\xi = \\frac{y&#8217;}{t&#8217;^b}$$<\/p>\n\n\n\n<p>, where <span class=\"katex math inline\">a<\/span>, and <span class=\"katex math inline\">b<\/span> are indefinite variables.<\/p>\n\n\n\n<p>Again, don&#8217;t ask why it is in this form, because it is a <strong>special<\/strong> solution!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4.2 Derivation<\/h3>\n\n\n\n<p>$$\\frac{\\partial p}{\\partial y&#8217;}=t&#8217;^{a-b}\\frac{df}{d\\xi}$$<\/p>\n\n\n\n<p>$$\\frac{\\partial^2 p}{\\partial y&#8217;^2}=t&#8217;^{a-2b}\\frac{d^2f}{d\\xi^2}$$<\/p>\n\n\n\n<p>$$\\frac{\\partial p}{\\partial t&#8217;}=at&#8217;^{a-1}f(\\xi)+by&#8217;t&#8217;^{a-b-1}\\frac{df}{d\\xi}$$<\/p>\n\n\n\n<p>Substitue back into the forward Kolmogorov equation (remember <span class=\"katex math inline\">y&#8217; = t&#8217;^b \\xi<\/span>), we get,<\/p>\n\n\n\n<p>$$ af(\\xi) &#8211; b\\xi \\frac{df}{d\\xi} = c^2 t&#8217;^{-2b+1} \\frac{d^2f}{d\\xi^2}$$<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4.3 Choose <span class=\"katex math inline\">b<\/span><\/h3>\n\n\n\n<p>As we need the RHS to be independent of <span class=\"katex math inline\">t&#8217;<\/span>, we could choose the value of <span class=\"katex math inline\">b=\\frac{1}{2}<\/span>, to let the <span class=\"katex math inline\">t&#8217;<\/span> has a power of 0. Why we do that? Because we aim to reduce the partial differential equation to be a ordinary differential equation, in which the only variable is <span class=\"katex math inline\">\\xi<\/span>, and <span class=\"katex math inline\">t&#8217;<\/span> disappear.<\/p>\n\n\n\n<p>By assuming the special form of <span class=\"katex math inline\">p<\/span>, and letting <span class=\"katex math inline\">b= 1\/2<\/span>, our forward Kolmogorov becomes,<\/p>\n\n\n\n<p>$$ af(\\xi) &#8211; \\frac{1}{2}\\xi \\frac{df}{d\\xi} = c^2 \\frac{d^2f}{d\\xi^2}$$<\/p>\n\n\n\n<p>$$ p=t&#8217;^a f(\\frac{y&#8217;}{\\sqrt{t&#8217;}}) = t&#8217;^a f(\\xi)$$<\/p>\n\n\n\n<p>$$ \\xi = \\frac{y&#8217;}{\\sqrt{t&#8217;}}$$<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4.4 Choose <span class=\"katex math inline\">a<\/span><\/h3>\n\n\n\n<p>$$p=t&#8217;^a f(\\frac{y&#8217;}{\\sqrt{t&#8217;}}) $$<\/p>\n\n\n\n<p>We know that <span class=\"katex math inline\">p<\/span> is the transition p.d.f., its integral must be equal to &#8216;1&#8217;. <span class=\"katex math inline\">t&#8217;<\/span> is independent by the definition of random walk behaviour, so we do only integrate <span class=\"katex math inline\">p<\/span>, w.r.t. <span class=\"katex math inline\">y&#8217;<\/span>.<\/p>\n\n\n\n<p>$$\\int_{\\mathbb{R}}p\\ dy&#8217; = \\int_{\\mathbb{R}} t&#8217;^a f(\\frac{y&#8217;}{\\sqrt{t&#8217;}})\\ dy&#8217; = 1$$<\/p>\n\n\n\n<p>$$ \\int_{\\mathbb{R}} t&#8217;^a f(\\frac{y&#8217;}{\\sqrt{t&#8217;}})\\ dy&#8217; = 1 $$<\/p>\n\n\n\n<p>, by replace <span class=\"katex math inline\">x = \\frac{y&#8217;}{\\sqrt{t&#8217;}}<\/span>,<\/p>\n\n\n\n<p>$$ \\int_{\\mathbb{R}} t&#8217;^{a+1\/2} f(x)\\ dx =t&#8217;^{a+1\/2} \\int_{\\mathbb{R}} f(x)\\ dx= 1 $$<\/p>\n\n\n\n<p>$t&#8217;$ is independent, so the above equation would be equal to &#8216;1&#8217; regardless the power of $t&#8217;$. Thus, $a = -\\frac{1}{2}$ for sure.<\/p>\n\n\n\n<p>Also, we get <span class=\"katex math inline\">\\int_{\\mathbb{R}} f(x)\\ dx= 1<\/span>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4.5 Integrate! Solve it!<\/h3>\n\n\n\n<p>By assuming the special form of <span class=\"katex math inline\">p<\/span>, and letting <span class=\"katex math inline\">a=-1\/2<\/span>, <span class=\"katex math inline\">b=1\/2<\/span>, we get,<\/p>\n\n\n\n<p>$$ -\\frac{1}{2}f(\\xi) &#8211; \\frac{1}{2}\\xi \\frac{df}{d\\xi} = c^2 \\frac{d^2f}{d\\xi^2}$$<\/p>\n\n\n\n<p>$$ p=\\frac{1}{\\sqrt{t&#8217;}} f(\\frac{y&#8217;}{\\sqrt{t&#8217;}}) = \\frac{1}{\\sqrt{t&#8217;}}f(\\xi)$$<\/p>\n\n\n\n<p>$$ \\xi = \\frac{y&#8217;}{\\sqrt{t&#8217;}}$$<\/p>\n\n\n\n<p>The forward Kolmogorov equation becomes,<\/p>\n\n\n\n<p>$$ -\\frac{1}{2}\\bigg(f(\\xi) &#8211; \\xi \\frac{df}{d\\xi} \\bigg)= c^2 \\frac{d^2f}{d\\xi^2}$$<\/p>\n\n\n\n<p>$$ -\\frac{1}{2}\\bigg( \\frac{d \\xi f(\\xi)}{d \\xi} \\bigg)= c^2 \\frac{d^2f}{d\\xi^2}$$<\/p>\n\n\n\n<p>, as <span class=\"katex math inline\">f(\\xi) &#8211; \\xi \\frac{df}{d\\xi} = \\frac{d \\xi f(\\xi)}{d \\xi}<\/span>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Integrate 1st Time<\/h4>\n\n\n\n<p>$$ -\\frac{1}{2}\\xi f(\\xi)= c^2 \\frac{df}{d\\xi} + constant$$<\/p>\n\n\n\n<p>There\u2019s an arbitrary constant of integration that could go in here but for the answer we want this is zero. We need only a special solution, so we can set that arbitrary constant term be zero.<\/p>\n\n\n\n<p>So, the eq could be rewritten as,<\/p>\n\n\n\n<p>$$ -\\frac{1}{2c^2}\\xi d\\xi = \\frac{1}{f(\\xi)}df $$<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Integrate 2nd Time<\/h4>\n\n\n\n<p>$$ ln\\ f(\\xi) = -\\frac{\\xi^2}{4c^2} + C$$<\/p>\n\n\n\n<p>Take exponential, <span class=\"katex math inline\">f(\\xi) = e^C e^{-\\frac{\\xi^2}{4c^2}} = A e^{-\\frac{\\xi^2}{4c^2}}<\/span> .<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Find <span class=\"katex math inline\">A<\/span><\/h4>\n\n\n\n<p>The Last Step here is to find the exact value of <span class=\"katex math inline\">A<\/span>. <span class=\"katex math inline\">A<\/span> is chosen such that the integral of <span class=\"katex math inline\">f<\/span> is one.<\/p>\n\n\n\n<p>$$\\int_{\\mathbb{R}}f(\\xi)\\ d\\xi =1$$<\/p>\n\n\n\n<p>$$ \\int_{\\mathbb{R}}A e^{-\\frac{\\xi^2}{4c^2}} \\ d\\xi = 2cA\\int_{\\mathbb{R}} e^{-\\frac{\\xi^2}{4c^2}} \\ d\\big(\\frac{\\xi}{2c}\\big) =1 $$<\/p>\n\n\n\n<p>$$ 2cA \\sqrt{\\pi} = 1 $$<\/p>\n\n\n\n<p>, so we get <span class=\"katex math inline\">A = \\frac{1}{2c\\sqrt{\\pi}}<\/span><\/p>\n\n\n\n<p>Plug <span class=\"katex math inline\">f(\\xi), a, b, A<\/span> back into <span class=\"katex math inline\">p = t^a f(\\xi)<\/span>.<\/p>\n\n\n\n<p>$$ p(y&#8217;)=\\frac{1}{2c\\sqrt{\\pi \\ t&#8217;}}e^{-\\frac{\\xi^2}{4c^2}} =\\frac{1}{2c\\sqrt{\\pi \\ t&#8217;}}e^{-\\frac{y&#8217;^2}{4c^2t&#8217;}} $$<\/p>\n\n\n\n<p>$p(.)$ now is normal like distributed.<\/p>\n\n\n\n<p>$$N(x) = \\frac{1}{\\sqrt{2\\pi\\sigma^2}}e^{-\\frac{(x-\\mu)^2}{2\\sigma^2}}$$<\/p>\n\n\n\n<p>So, we may say <span class=\"katex math inline\">\\mu_{y&#8217;}=0<\/span>, and <span class=\"katex math inline\">\\sigma^2_{y&#8217;}=2c^2t&#8217;<\/span>. Or, <span class=\"katex math inline\">y&#8217; \\sim N(0, 2c^2t&#8217;)<\/span>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Summary<\/h2>\n\n\n\n<p>$$p(y&#8217;)=\\frac{1}{2c\\sqrt{\\pi \\ t&#8217;}}e^{-\\frac{\\xi^2}{4c^2}} =\\frac{1}{2c\\sqrt{\\pi \\ t&#8217;}}e^{-\\frac{y&#8217;^2}{4c^2t&#8217;}} $$<\/p>\n\n\n\n<p><strong>Finally, we solved the transition probability density function <span class=\"katex math inline\">p(.)<\/span><\/strong>. By assuming the forward or backward type of trinomial model, we find a partial differential relationship. Then, assuming a special form of <span class=\"katex math inline\">p(.)<\/span> by similarity method, we solve it.<\/p>\n\n\n\n<p>The meaning is that <span class=\"katex math inline\">p(y&#8217;)=\\frac{1}{2c\\sqrt{\\pi \\ t&#8217;}}e^{-\\frac{\\xi^2}{4c^2}} =\\frac{1}{2c\\sqrt{\\pi \\ t&#8217;}}e^{-\\frac{y&#8217;^2}{4c^2t&#8217;}}<\/span> is one of the transition probability density function that can satisfy the trinomial random walk.<\/p>\n\n\n\n<p>Also, we find that <span class=\"katex math inline\">p(.)<\/span> is normally liked distributed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>See my Github repo for full details. https:\/\/github.com\/eightsmile\/cqf 1. Trinomial Random Walk 2. Transition Probability Density Function The transition probability density function, p(y,t;y&#8217;,t&#8217;), is defined by, $$ Prob(a&lt;y'&lt;b, at\\ time \\ t&#8217; | y \\ at \\ time\\ t) = \\int_a^b p(yet;y&#8217;,t&#8217;)dy&#8217;$$ In words this is \u201cthe probability that the random variable y \u2032 lies &hellip; <a href=\"https:\/\/fanyuzhao.com\/?p=5524\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Taylor Series and Transition Density Functions<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,18,26],"tags":[],"_links":{"self":[{"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=\/wp\/v2\/posts\/5524"}],"collection":[{"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5524"}],"version-history":[{"count":8,"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=\/wp\/v2\/posts\/5524\/revisions"}],"predecessor-version":[{"id":5533,"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=\/wp\/v2\/posts\/5524\/revisions\/5533"}],"wp:attachment":[{"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}