Because base-level sde objects accept drift and
diffusion objects in lieu of functions accessible by (t,
Xt), you can create sde objects with combinations of
customized drift or diffusion functions and objects. The drift and diffusion rate objects encapsulate
the details of input parameters to optimize run-time efficiency for any given
combination of input parameters.
Although drift and diffusion objects differ in the
details of their representation, they are identical in their basic implementation
and interface. They look, feel like, and are evaluated as functions:
The drift object allows you to create drift-rate objects of the form:
where:
A is an
NVars-by-1
vector-valued function accessible using the
(t,
Xt)
interface.
B is an
NVars-by-NVars
matrix-valued function accessible using the
(t,
Xt) interface.
Similarly, the diffusion object allows you
to create diffusion-rate objects:
where:
D is an
NVars-by-NVars
diagonal matrix-valued 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 an NVars-by-1
vector-valued function.
V is an
NVars-by-NBrowns
matrix-valued volatility rate function
Sigma.
Alpha and Sigma are also
accessible using the (t,
Xt)
interface.
Note
You can express drift and diffusion objects in
the most general form to emphasize the functional
(t,
Xt) interface.
However, you can specify the components A and
B as functions that adhere to the common
(t,
Xt) interface, or as
MATLAB® arrays of appropriate dimension.
In this example, you create drift and diffusion rate objects to create the
same model as in Example: Base SDE Models.
Create a drift-rate function F and a diffusion-rate
function G:
F = drift(0, 0.1) % Drift rate function F(t,X)F =
Class DRIFT: Drift Rate Specification
-------------------------------------
Rate: drift rate function F(t,X(t))
A: 0
B: 0.1
G = diffusion(1, 0.3) % Diffusion rate function G(t,X)G =
Class DIFFUSION: Diffusion Rate Specification
---------------------------------------------
Rate: diffusion rate function G(t,X(t))
Alpha: 1
Sigma: 0.3
Each object displays like a MATLAB structure and contains supplemental information, namely, the object's
class and a brief description. However, in contrast to the SDE representation, a
summary of the dimensionality of the model does not appear, because drift and diffusion objects create model
components rather than models. Neither F nor G
contains enough information to characterize the dimensionality of a problem.
The drift object's displayed parameters are:
Rate: The drift-rate function,
F(t,Xt)
A: The intercept term,
A(t,Xt), of
F(t,Xt)
B: The first order term,
B(t,Xt), of
F(t,Xt)
A and B enable you to query the
original inputs. The function stored in Rate fully encapsulates
the combined effect of A and B.
The diffusion object's displayed parameters are:
Rate: The diffusion-rate function, G(t,Xt).
Alpha: The state vector exponent,
which determines the format of D(t,Xt) of G(t,Xt).
Sigma: The volatility rate, V(t,Xt),
of G(t,Xt).
Again, Alpha and Sigma enable
you to query the original inputs. (The combined effect of the individual Alpha and Sigma parameters
is fully encapsulated by the function stored in Rate.)
The Rate functions are the calculation engines
for the drift and diffusion objects,
and are the only parameters required for simulation.
The sdeddo object derives from the basesde object. To use this object, you
must pass drift and diffusion-rate objects to sdeddo.
Create drift and diffusion rate
objects:
F = drift(0, 0.1); % Drift rate function F(t,X) G = diffusion(1, 0.3); % Diffusion rate function G(t,X)
Pass these objects to the sdeddo object:
obj = sdeddo(F, G) % dX = F(t,X)dt + G(t,X)dWobj =
Class SDEDDO: SDE from Drift and Diffusion Objects
--------------------------------------------------
Dimensions: State = 1, Brownian = 1
--------------------------------------------------
StartTime: 0
StartState: 1
Correlation: 1
Drift: drift rate function F(t,X(t))
Diffusion: diffusion rate function G(t,X(t))
Simulation: simulation method/function simByEuler
A: 0
B: 0.1
Alpha: 1
Sigma: 0.3
In this example, the object displays the additional parameters associated with input drift and diffusion objects.
bates | bm | cev | cir | diffusion | drift | gbm | heston | hwv | interpolate | merton | sde | sdeddo | sdeld | sdemrd | simByEuler | simByQuadExp | simBySolution | simBySolution | simulate | ts2func