Drift and Diffusion Models
Overview
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 - driftobject allows you to create drift-rate objects of the form:- where: - Ais an- NVars-by-- 1vector-valued function accessible using the (t, Xt) interface.
- Bis an- NVars-by-- NVarsmatrix-valued function accessible using the (t, Xt) interface.
 
- Similarly, the - diffusionobject allows you to create diffusion-rate objects:- where: - Dis an- NVars-by-- NVarsdiagonal matrix-valued function.
- Each diagonal element of - Dis the corresponding element of the state vector raised to the corresponding element of an exponent- Alpha, which is an- NVars-by-- 1vector-valued function.
- Vis an- NVars-by-- NBrownsmatrix-valued volatility rate function- Sigma.
- Alphaand- Sigmaare also accessible using the (t, Xt) interface.
 - Note - You can express - driftand- diffusionobjects in the most general form to emphasize the functional (t, Xt) interface. However, you can specify the components- Aand- Bas functions that adhere to the common (t, Xt) interface, or as MATLAB® arrays of appropriate dimension.
Specify Drift and Diffusion Rate Functions
In this example, you create drift and diffusion rate objects to create the same model as in Specify Base Stochastic Differential Equation (SDE) Model.
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,
- A: The intercept term, , of
- B: The first order term, , of
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, 
- Alpha: The state vector exponent, which determines the format of of
- Sigma: The volatility rate, , of
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. 
Specify SDEDDO with Drift and Diffusion Functions
The sdeddo object derives from the base sde object. To use this object, you must pass drift and diffusion 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 drift and diffusion 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
See Also
sde | bm | gbm | merton | bates | drift | diffusion | sdeddo | sdeld | cev | cir | heston | hwv | sdemrd | rvm | roughbergomi | roughheston | ts2func | simulate | simByEuler | simBySolution | simBySolution | interpolate | simByQuadExp