Main Content

# simByTransition

Simulate Heston sample paths with transition density

## Syntax

``[Paths,Times] = simByTransition(MDL,NPeriods)``
``[Paths,Times] = simByTransition(___,Name,Value)``

## Description

example

````[Paths,Times] = simByTransition(MDL,NPeriods)` simulates `NTrials` sample paths of Heston bivariate models driven by two Brownian motion sources of risk. `simByTransition` approximates continuous-time stochastic processes by the transition density.```

example

````[Paths,Times] = simByTransition(___,Name,Value)` specifies options using one or more name-value pair arguments in addition to the input arguments in the previous syntax.```

## Examples

collapse all

Simulate Heston sample paths with transition density.

Define the parameters for the `heston` object.

```Return = 0.03; Level = 0.05; Speed = 1.0; Volatility = 0.2; AssetPrice = 80; V0 = 0.04; Rho = -0.7; StartState = [AssetPrice;V0]; Correlation = [1 Rho;Rho 1];```

Create a `heston` object.

`hestonObj = heston(Return,Speed,Level,Volatility,'startstate',StartState,'correlation',Correlation)`
```hestonObj = Class HESTON: Heston Bivariate Stochastic Volatility ---------------------------------------------------- Dimensions: State = 2, Brownian = 2 ---------------------------------------------------- StartTime: 0 StartState: 2x1 double array Correlation: 2x2 double array Drift: drift rate function F(t,X(t)) Diffusion: diffusion rate function G(t,X(t)) Simulation: simulation method/function simByEuler Return: 0.03 Speed: 1 Level: 0.05 Volatility: 0.2 ```

Define the simulation parameters.

```nPeriods = 5; % Simulate sample paths over the next five years Paths = simByTransition(hestonObj,nPeriods); Paths```
```Paths = 6×2 80.0000 0.0400 92.9915 0.0343 108.6211 0.0737 52.9617 0.1012 46.9805 0.1243 54.3704 0.0571 ```

## Input Arguments

collapse all

Stochastic differential equation model, specified as a `heston` object. For more information on creating a `heston` object, see `heston`.

Data Types: `object`

Number of simulation periods, specified as a positive scalar integer. The value of `NPeriods` determines the number of rows of the simulated output series.

Data Types: `double`

### Name-Value Arguments

Specify optional comma-separated pairs of `Name,Value` arguments. `Name` is the argument name and `Value` is the corresponding value. `Name` must appear inside quotes. You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

Example: ```[Paths,Times] = simByTransition(Heston,NPeriods,'DeltaTimes',dt)```

Simulated trials (sample paths) of `NPeriods` observations each, specified as the comma-separated pair consisting of `'NTrials'` and a positive scalar integer.

Data Types: `double`

Positive time increments between observations, specified as the comma-separated pair consisting of `'DeltaTimes'` and a scalar or `NPeriods`-by-`1` column vector.

`DeltaTime` represents the familiar dt found in stochastic differential equations, and determines the times at which the simulated paths of the output state variables are reported.

Data Types: `double`

Number of intermediate time steps within each time increment dt (defined as `DeltaTimes`), specified as the comma-separated pair consisting of `'NSteps'` and a positive scalar integer.

The `simByTransition` function partitions each time increment dt into `NSteps` subintervals of length dt/`NSteps`, and refines the simulation by evaluating the simulated state vector at `NSteps − 1` intermediate points. Although `simByTransition` does not report the output state vector at these intermediate points, the refinement improves accuracy by enabling the simulation to more closely approximate the underlying continuous-time process.

Data Types: `double`

Flag for storage and return method that indicates how the output array `Paths` is stored and returned, specified as the comma-separated pair consisting of `'StorePaths'` and a scalar logical flag with a value of `True` or `False`.

• If `StorePaths` is `True` (the default value) or is unspecified, then `simByTransition` returns `Paths` as a three-dimensional time series array.

• If `StorePaths` is `False` (logical `0`), then `simByTransition` returns the `Paths` output array as an empty matrix.

Data Types: `logical`

Sequence of end-of-period processes or state vector adjustments, specified as the comma-separated pair consisting of `'Processes'` and a function or cell array of functions of the form

`${X}_{t}=P\left(t,{X}_{t}\right)$`

`simByTransition` applies processing functions at the end of each observation period. The processing functions accept the current observation time t and the current state vector Xt, and return a state vector that might adjust the input state.

If you specify more than one processing function, `simByTransition` invokes the functions in the order in which they appear in the cell array.

Data Types: `cell` | `function`

## Output Arguments

collapse all

Simulated paths of correlated state variables, returned as an ```(NPeriods + 1)```-by-`NVars`-by-`NTrials` three-dimensional time series array.

For a given trial, each row of `Paths` is the transpose of the state vector Xt at time t. When the input flag `StorePaths` = `False`, `simByTransition` returns `Paths` as an empty matrix.

Observation times associated with the simulated paths, returned as an `(NPeriods + 1)`-by-`1` column vector. Each element of `Times` is associated with the corresponding row of `Paths`.

## More About

collapse all

### Transition Density Simulation

The CIR SDE has no solution such that r(t) = f(r(0),⋯).

In other words, the equation is not explicitly solvable. However, the transition density for the process is known.

The exact simulation for the distribution of r(t_1 ),⋯,r(t_n) is that of the process at times t_1,⋯,t_n for the same value of r(0). The transition density for this process is known and is expressed as

`$\begin{array}{l}r\left(t\right)=\frac{{\sigma }^{2}\left(1-{e}^{-\alpha \left(t-u\right)}}{4\alpha }{x}_{d}^{2}\left(\frac{4\alpha {e}^{-\alpha \left(t-u\right)}}{{\sigma }^{2}\left(1-{e}^{-\alpha \left(t-u\right)}\right)}r\left(u\right)\right),t>u\\ \text{where}\\ d\equiv \frac{4b\alpha }{{\sigma }^{2}}\end{array}$`

### Heston Model

Heston models are bivariate composite models.

Each Heston model consists of two coupled univariate models:

• A geometric Brownian motion (`gbm`) model with a stochastic volatility function.

`$d{X}_{1t}=B\left(t\right){X}_{1t}dt+\sqrt{{X}_{2t}}{X}_{1t}d{W}_{1t}$`

This model usually corresponds to a price process whose volatility (variance rate) is governed by the second univariate model.

• A Cox-Ingersoll-Ross (`cir`) square root diffusion model.

`$d{X}_{2t}=S\left(t\right)\left[L\left(t\right)-{X}_{2t}\right]dt+V\left(t\right)\sqrt{{X}_{2t}}d{W}_{2t}$`

This model describes the evolution of the variance rate of the coupled GBM price process.

## References

[1] Glasserman, Paul Monte Carlo Methods in Financial Engineering. New York: Springer-Verlag, 2004.

[2] Van Haastrecht, Alexander, and Antoon Pelsser. "Efficient, Almost Exact Simulation of the Heston Stochastic Volatility Model." International Journal of Theoretical and Applied Finance. 13, no. 01 (2010): 1–43.

## See Also

### Topics

Introduced in R2020b

Download ebook