Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Because base-level `sde`

objects accept drift and
diffusion objects in lieu of functions accessible by (*t*,
*X _{t}*), 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:$$F(t,{X}_{t})=A(t)+B(t){X}_{t}$$

where:

`A`

is an`NVARS`

-by-`1`

vector-valued function accessible using the (*t*,*X*) interface._{t}`B`

is an`NVARS`

-by-`NVARS`

matrix-valued function accessible using the (*t*,*X*) interface._{t}

Similarly, the

`diffusion`

object allows you to create diffusion-rate objects:$$G(t,{X}_{t})=D(t,{X}_{t}^{\alpha (t)})V(t)$$

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*,*X*) interface._{t}

### Note

You can express

`drift`

and`diffusion`

objects in the most general form to emphasize the functional (*t*,*X*) interface. However, you can specify the components_{t}`A`

and`B`

as functions that adhere to the common (*t*,*X*) interface, or as MATLAB_{t}^{®}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,X*_{t})`A`

: The intercept term,*A(t,X*, of_{t})*F(t,X*_{t})`B`

: The first order term,*B(t,X*, of_{t})*F(t,X*_{t})

`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,X*._{t})`Alpha`

: The state vector exponent, which determines the format of*D(t,X*of_{t})*G(t,X*._{t})`Sigma`

: The volatility rate,*V(t,X*, of_{t})*G(t,X*._{t})

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 base`sde`

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)dW`

obj = 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.

`bm`

| `cev`

| `cir`

| `diffusion`

| `drift`

| `gbm`

| `heston`

| `hwv`

| `interpolate`

| `sde`

| `sdeddo`

| `sdeld`

| `sdemrd`

| `simByEuler`

| `simBySolution`

| `simBySolution`

| `simulate`

| `ts2func`