Volume 9, Issue 4
Tricks of the Trade
In and Out
Download This Issue
Staff and Contributors
Stochastic Integrals and Their Expectations
This article describes the Mathematica package ItoIntegralRules that provides facilities to simplify and compute expectations of stochastic integrals. ItoIntegralRules extends the previous package Itovsn3 [1, 2] that implements stochastic calculus within Mathematica.
Stochastic calculus is famous for providing the foundations for modern mathematical finance and is also used extensively in a large number of other areas of applied probability. The introductory text by Øksendal  strikes an excellent balance between theory and accessibility. Here we give a very brief review of the underlying concepts. A central notion for stochastic calculus is that of a (continuous) semimartingale: a random process X that can be written as the sum of a local martingale M (for example, Brownian motion) and a drift process V (a continuous process of locally bounded variation, typically the solution of some conventional differential equation). The decomposition is unique and can be thought of as a decomposition of X into signal V plus noise M. Fundamental to the theory of stochastic calculus is Itô's lemma: if is a smooth function of the semimartingale X, then
where is the quadratic variation, the unique nondecreasing process such that is a local martingale begun at 0. In the case when M is Brownian motion, we find . Care has to be taken when interpreting the integral : nontrivial continuous local martingales M do not possess bounded variation, so the component of must be interpreted as a stochastic or Itô integral. (Since V is of locally bounded variation, the interpretation of is strictly classical.)
Itô's lemma, in conjunction with martingale theory, permits us to calculate effectively with semimartingales in Mathematica. In Itovsn3 [1, 2] the underlying algebra of stochastic calculus is implemented as an algebra of stochastic differentials dX, dM, and dV. This has facilitated several investigations into applied probability problems: examples given in  include explorations of the statistical theory of shape, coupling of diffusions, and computation of distributions of special random processes. The underlying principle of Itovsn3 is to recognize a second-order algebraic structure of differentials corresponding to the formula for Itô's lemma. Thus semimartingales X have stochastic differentials dX that can be multiplied together to obtain a differential measure of volatility of the semimartingale (for example, ) and that possess drift parts that capture the underlying trend ( if ).
The need to perform some calculations related to an image analysis problem [4, 5] supplied the initial motivation to extend Itovsn3 by adding the package ItoIntegralRules to more fully implement a notion of Itô integral, such as or . Itô integrals are represented in Itovsn3 using placeholders ItoIntegral[g dM] that possess the bare minimum of properties (loosely speaking, ItoIntegral[dM] -> M). The new package ItoIntegralRules adds facilities to simplify expressions involving ItoIntegral in various ways and also adds an expectation operator . In particular, this allows us to address the calculations arising from the image analysis problem, which requires the derivation and further manipulation of formulas for means and variances for integrated Ornstein-Uhlenbeck processes. These specific calculations can of course be performed directly by hand; however, the computational framework provided by ItoIntegralRules covers a much wider range of possible calculations, so it should be of use elsewhere.
This article is divided into three sections: the first summarizes the issues of simplification of expressions involving ItoIntegral, the second introduces a notion of expectation and its interaction with ItoIntegral, and the conclusion discusses possibilities for further work.
There are other implementations of stochastic calculus within a computer algebra package. Steele and Stine  adopt a diffusion-based approach, which has been developed further by Mark Fisher in the ItosLemma.m package . Cyganowski  describes an approach using Maple, including a solver for stochastic differential equations.
The installation of Itovsn3 and ItoIntegralRules follows the usual procedure for Mathematica packages. Unpack the zip archive file Itovsn3.zip (see Additional Material) either in the current working directory or in the Applications subdirectory of Mathematica's AddOns directory (in the second case the packages will load no matter what is the current working directory). This will place the files init.m (which contains the package Itovsn3), ItoIntegralRules.m, and ItoIntegralTests.nb in the Itovsn3 subdirectory. The accompanying notebook, ItoIntegralTests.nb, contains detailed examples and unit tests for ItoIntegralRules.
After installation, Itovsn3 can be loaded and initialized and a single Brownian motion B can be introduced by
About Mathematica | Download Mathematica Player
© Wolfram Media, Inc. All rights reserved.