SDE Models
Introduction
Most models and utilities available with Monte Carlo Simulation of SDEs are represented as MATLAB^{®} objects. Therefore, this documentation often uses the terms model and object interchangeably.
However, although all models are represented as objects, not all objects represent
models. In particular, drift
, diffusion
objects are used in model
specification, but neither of these types of objects in and of themselves makes up a
complete model. Usually, you do not need to create drift
, diffusion
objects directly, so you do
not need to differentiate between objects and models. It is important, however, to
understand the distinction between these terms.
In many of the following examples, most model parameters are evaluated or invoked like any MATLAB function. Although it is helpful to examine and access model parameters as you would data structures, think of these parameters as functions that perform actions.
Creating SDE Objects
Creating Objects
For examples and more information on creating SDE objects, see:
Displaying Objects
Objects display like traditional MATLAB data structures.
Displayed object parameters appear as nouns that begin with capital letters. In contrast, parameters such as
simulate
andinterpolate
appear as verbs that begin with lowercase letters, which indicate tasks to perform.
Assigning and Referencing Object Parameters
Objects support referencing similar to data structures. For example, statements like the following are valid:
A = obj.A
Objects support complete parameter assignment similar to data structures. For example, statements like the following are valid:
obj.A = 3
Objects do not support partial parameter assignment as data structures do. Therefore, statements like the following are invalid:
obj.A(i,j) = 0.3
Creating and Evaluating Models
You can create objects of any model class only if enough information is available to determine unambiguously the dimensionality of the model. Because each object offers unique input interfaces, some models require additional information to resolve model dimensionality.
You need only enter required input parameters in placeholder format, where a given input argument is associated with a specific position in an argument list. You can enter optional inputs in any order as parameter namevalue pairs, where the name of a given parameter appears in single quotation marks and precedes its corresponding value.
Association of dynamic (timevariable) behavior with function evaluation, where time and state (t,X_{t}) are passed to a common, published interface, is pervasive throughout the SDE class system. You can use this function evaluation approach to model or construct powerful analytics. For a simple example, see Example: Univariate GBM Models.
Specifying SDE Simulation Parameters
The SDE engine allows the simulation of generalized multivariate stochastic processes, and provides a flexible and powerful simulation architecture. The framework also provides you with utilities and model classes that offer various parametric specifications and interfaces. The architecture is fully multidimensional in both the state vector and the Brownian motion, and offers both linear and meanreverting driftrate specifications.
You can specify most parameters as MATLAB arrays or as functions accessible by a common interface, that supports general dynamic/nonlinear relationships common in SDE simulation. Specifically, you can simulate correlated paths of any number of state variables driven by a vectorvalued Brownian motion of arbitrary dimensionality. This simulation approximates the underlying multivariate continuoustime process using a vectorvalued stochastic difference equation.
Consider the following general stochastic differential equation:
$$d{X}_{t}=F(t,{X}_{t})dt+G(t,{X}_{t})d{W}_{t}$$  (1) 
where:
X is an NVarsby
1
state vector of process variables (for example, short rates or equity prices) to simulate.W is an NBrownsby
1
Brownian motion vector.F is an NVarsby
1
vectorvalued driftrate function.G is an NVarsbyNBrowns matrixvalued diffusionrate function.
The drift and diffusion rates, F and G, respectively, are general functions of a realvalued scalar sample time t and state vector X_{t}. Also, static (nontimevariable) coefficients are simply a special case of the more general dynamic (timevariable) situation, just as a function can be a trivial constant; for example, f(t,X_{t}) = 4. The SDE in Equation 1 is useful in implementing derived classes that impose additional structure on the drift and diffusionrate functions.
Specifying UserDefined Functions as Model Parameters. Several examples in this documentation emphasize the evaluation of object parameters as functions accessible by a common interface. In fact, you can evaluate object parameters by passing to them time and state, regardless of whether the underlying userspecified parameter is a function. However, it is helpful to compare the behavior of object parameters that are specified as functions to that of userspecified noise and endofperiod processing functions.
Model parameters that are specified as functions are evaluated in the same way as userspecified random number (noise) generation functions. (For more information, see Evaluating Different Types of Functions.) Model parameters that are specified as functions are inputs to remove object constructors. Userspecified noise and processing functions are optional inputs to simulation methods.
Because class constructors offer unique interfaces, and simulation methods of any given model have different implementation details, models often call parameter functions for validation purposes a different number of times, or in a different order, during object creation, simulation, and interpolation.
Therefore, although parameter functions, userspecified noise generation
functions, and endofperiod processing functions all share the interface
and are validated at the same initial time and state (obj.StartTime
and obj.StartState
), parameter functions are
not guaranteed to be invoked only once before simulation as noise generation
and endofperiod processing functions are. In fact, parameter functions
might not even be invoked the same number of times during a given Monte
Carlo simulation process.
In most applications in which you specify parameters as functions, they are simple, deterministic functions of time and/or state. There is no need to count periods, count trials, or otherwise accumulate information or synchronize time.
However, if parameter functions require more sophisticated bookkeeping,
the correct way to determine when a simulation has begun (or equivalently,
to determine when model validation is complete) is to determine when the
input time and/or state differs from the initial time and state
(obj.StartTime
and obj.StartState
,
respectively). Because the input time is a known scalar, detecting a change
from the initial time is likely the best choice in most situations. This is
a general mechanism that you can apply to any type of userdefined
function.
Evaluating Different Types of Functions. It is useful to compare the evaluation rules of userspecified noise generation functions to those of endofperiod processing functions. These functions have the following in common:
They both share the same general interface, returning a column vector of appropriate length when evaluated at the current time and state:
$${X}_{t}=f(t,{X}_{t})$$
$${z}_{t}=Z(t,{X}_{t})$$
Before simulation, the simulation method itself calls each function once to validate the size of the output at the initial time and state,
obj.StartTime
, andobj.StartState
, respectively.During simulation, the simulation method calls each function the same number of times:
NPeriods
*NSteps
.
However, there is an important distinction regarding the
timing between these two types of functions. It is most clearly drawn
directly from the generic SDE
model:
$$d{X}_{t}=F(t,{X}_{t})dt+G(t,{X}_{t})d{W}_{t}$$
This equation is expressed in continuous time, but the simulation methods approximate the model in discrete time as:
$${X}_{t+\Delta t}={X}_{t}+F(t,{X}_{t})\Delta t+G(t,{X}_{t})\sqrt{\Delta t}Z(t,{X}_{t})$$
where Δt > 0 is a small (and not necessarily equal) period or time increment into the future. This equation is often referred to as a Euler approximation, a simulation technique that provides a discretetime approximation of a continuoustime stochastic process. All functions on the rightmost side are evaluated at the current time and state (t, X_{t}).
In other words, over the next small time increment, the simulation evolves the state vector based only on information available at the current time and state. In this sense, you can think of the noise function as a beginningofperiod function, or as a function evaluated from the left. This is also true for any usersupplied drift or diffusion function.
In contrast, userspecified endofperiod processing functions are applied only at the end of each simulation period or time increment. For more information about processing functions, see Pricing Equity Options.
Therefore, all simulation methods evaluate noise generation functions as:
$${z}_{t}=Z(t,{X}_{t})$$
for t = t_{0}, t_{0} + Δt, t_{0} + 2Δt, ..., T – Δt.
Yet simulation methods evaluate endofperiod processing functions as:
$${X}_{t}=f(t,{X}_{t})$$
for t = t_{0} + Δt, t_{0} + 2Δt, ..., T.
where t_{0} and T are the initial time (taken from the object) and the terminal time (derived from inputs to the simulation method), respectively. These evaluations occur on all sample paths. Therefore, during simulation, noise functions are never evaluated at the final (terminal) time, and endofperiod processing functions are never evaluated at the initial (starting) time.
Drift and Diffusion
For example, an SDE with a linear drift rate has the form:
$$F(t,{X}_{t})=A(t)+B(t){X}_{t}$$  (2) 
where A is an NVarsby1
vectorvalued function and B is an
NVarsbyNVars matrixvalued function.
As an alternative, consider a driftrate specification expressed in meanreverting form:
$$F(t,{X}_{t})=S(t)[L(t){X}_{t}]$$  (3) 
where S is an
NVarsbyNVars matrixvalued function of
mean reversion speeds (that is, rates of mean reversion), and L
is an NVarsby1
vectorvalued function of
mean reversion levels (that is, long run average level).
Similarly, consider the following diffusionrate specification:
$$G(t,{X}_{t})=D(t,{X}_{t}^{\alpha (t)})V(t)$$  (4) 
where D is an
NVarsbyNVars diagonal matrixvalued
function. Each diagonal element of D is the corresponding element
of the state vector raised to the corresponding element of an exponent
Alpha, which is also an
NVarsby1
vectorvalued function.
V is an
NVarsbyNBrowns matrixvalued function of
instantaneous volatility rates. Each row of V corresponds to a
particular state variable, and each column corresponds to a particular Brownian
source of uncertainty. V associates the exposure of state
variables with sources of risk.
The parametric specifications for the drift and diffusionrate functions associate parametric restrictions with familiar models derived from the general SDE class, and provide coverage for many models.
The class system and hierarchy of the SDE engine use industrystandard terminology to provide simplified interfaces for many models by placing usertransparent restrictions on drift and diffusion specifications. This design allows you to mix and match existing models, and customize driftrate or diffusionrate functions.
Available Models
For example, the following models are special cases of the general SDE model.
SDE Models
Model Name  Specification 

Brownian Motion (BM) 
$$d{X}_{t}=A(t)dt+V(t)d{W}_{t}$$

Geometric Brownian Motion (GBM) 
$$d{X}_{t}=B(t){X}_{t}dt+V(t){X}_{t}d{W}_{t}$$

Constant Elasticity of Variance (CEV) 
$$d{X}_{t}=B(t){X}_{t}dt+V(t){X}_{t}^{\alpha (t)}d{W}_{t}$$

CoxIngersollRoss (CIR) 
$$d{X}_{t}=S(t)(L(t){X}_{t})dt+V(t){X}_{t}^{\frac{1}{2}}d{W}_{t}$$

HullWhite/Vasicek (HWV) 
$$d{X}_{t}=S(t)(L(t){X}_{t})dt+V(t)d{W}_{t}$$

Heston 
$$d{X}_{1t}=B(t){X}_{1t}dt+\sqrt{{X}_{2t}}{X}_{1t}d{W}_{1t}$$
$$d{X}_{2t}=S(t)[L(t){X}_{2t}]dt+V(t)\sqrt{{X}_{2t}}d{W}_{2t}$$

Merton 
$$d{X}_{t}=B(t,{X}_{t}){X}_{t}dt+D(t,{X}_{t})V(t,{x}_{t})d{W}_{t}+Y(t,{X}_{t}){X}_{t}d{N}_{t}$$

Bates  Bates models are bivariate composite models. Each Bates model consists of two coupled univariate models:

SDE Simulation and Interpolation Methods
The sde
class provides default simulation
and interpolation methods for all derived classes:
simulate
: Highlevel wrapper around the userspecified simulation method stored in theSimulation
propertysimByEuler
: Default Euler approximation simulation methodinterpolate
: Stochastic interpolation method (that is, Brownian bridge)
You can use the simBySolution
function to simulate approximate
solutions of diagonaldrift processes for the following classes:
gbm
supportssimBySolution
hwv
supportssimBySolution
merton
supportssimBySolution
You can use the simBySolution
function with the namevalue
arguments for MonteCarloMethod
and
QuasiSequence
to simulates approximate solutions of
quasiMonte Carlo simulations for the following classes:
gbm
supportssimBySolution
hwv
supportssimBySolution
merton
supportssimBySolution
In addition, you can also use:
simByTransition
with acir
object to approximates a continuoustime CoxIngersollRoss (CIR) model by an approximation of the transition density function.simByTransition
with abates
object to approximates a continuoustime Bates model by an approximation of the transition density function.simByTransition
with aheston
object to approximates a continuoustime Heston model by an approximation of the transition density function.simByQuadExp
with aheston
,bates
, orcir
object to generate sample paths by using a QuadraticExponential discretization scheme.
.
See Also
sde
 bm
 gbm
 merton
 bates
 drift
 diffusion
 sdeddo
 sdeld
 cev
 cir
 heston
 hwv
 sdemrd
 ts2func
 simulate
 simByEuler
 simBySolution
 simByQuadExp
 simBySolution
 interpolate