6
$\begingroup$

This is a follow-up question on this question: Use of Ito's lemma in ItoProcess

My problem is to find some method how to use Ito's lemma in Mathematica. As an example:

How can I apply Ito's lemma on the following stochastic differential equation (SDE) $dS=S(σdB+μdt)$, with $B$ being Brownian motion. Applying Itō's lemma with $f(S)=log(S)$ gives

$$\begin{align} d\log(S) & = f^\prime(S)\,dS + \frac{1}{2}f^{\prime\prime} (S)S^2\sigma^2 \,dt \\ & = \frac{1}{S} \left( \sigma S\,dB + \mu S\,dt\right) - \frac{1}{2}\sigma^2\,dt \\ &= \sigma\,dB +\left (\mu-\tfrac{\sigma^2}{2} \right )\,dt. \end{align}$$

It follows that

$$\log (S_t) = \log (S_0) + \sigma B_t + \left (\mu-\tfrac{\sigma^2}{2} \right )t,$$

exponentiating gives the expression for $S$,

$$S_t=S_0\exp\left(\sigma B_t+ \left (\mu-\tfrac{\sigma^2}{2} \right )t\right).$$

It was suggested to do the following:

[...] you'll need load the package ItosLemma, by Mark Fisher, that can be downloaded here: http://library.wolfram.com/infocenter/MathSource/1170/

The ItosLemma.nb has a clear example on how to use it. Following his example, you only need to load the package

<< ItosLemma`

and call ItoMake to represent the SDE satisfied by xt

dx = ItoMake[x[t], μ-σ^2/2, σ]

By denoting y = f(x,t), you should use the function ItoD[y] that gives you the Ito's lemma application for any "well behaved" function f.

y = f[x[t], t]
ItoD[y]

The problem that I have is that it assumes what I what to derive: basically the $-\tfrac{\sigma^2}{2}$ part.

The original SDE above was defined without it and it appeared in the derivation because of Ito's lemma!

My question
How can I use this package (or any other method) to arrive at the solution above with Mathematica?

$\endgroup$

2 Answers 2

7
$\begingroup$

Another possibility with built-in functions:

(* Define the process *)
proc = ItoProcess[ⅆs[t] == μ s[t] ⅆt +
 σ s[t] ⅆw[t], s[t], {s, s0}, {t, 0}, 
 w \[Distributed] WienerProcess[]]

Now the process can be used as:

Expectation[z, z \[Distributed] proc[t]]
(* E^(t μ) s0 *)

Simplify[Expectation[Log[z], z \[Distributed] proc[t]], 
  Assumptions -> {σ > 0}]
(* t (μ - σ^2/2) + Log[s0] *)
$\endgroup$
1
  • $\begingroup$ That's great, I was looking for something like that all the time! Thank you $\endgroup$
    – vonjd
    Jul 12, 2015 at 5:57
2
$\begingroup$

A comment from @Diogo brought me on the right track:

<<ItosLemma`
dS=ItoMake[S[t],μ *S,σ*S] 
(* dt S μ+S σ Subscript[dB, 1] *)

ItoD[Log[S[t]]]
(* dt (μ-σ^2/2)+σ Subscript[dB, 1] *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.