# simByMilstein2

Simulate diagonal diffusion `Merton`

sample paths by second
order Milstein approximation

*Since R2023b*

## Syntax

## Description

`[`

simulates `Paths`

,`Times`

,`Z`

,`N`

] = simByMilstein2(`MDL`

,`NPeriods`

)`NTrials`

sample paths of `NVars`

correlated state variables driven by `NBrowns`

Brownian motion
sources of risk and `NJumps`

compound Poisson processes
representing the arrivals of important events over `NPeriods`

consecutive observation periods. The simulation approximates the continuous-time
Merton jump diffusion process by the second order Milstein approximation.

`simByMilstein2`

is only valid for diagonal diffusion SDE
models.

`[`

specifies options using one or more name-value pair arguments in addition to the
input arguments in the previous syntax.`Paths`

,`Times`

,`Z`

,`N`

] = simByMilstein2(___,`Name=Value`

)

You can perform quasi-Monte Carlo simulations using the name-value arguments for
`MonteCarloMethod`

, `QuasiSequence`

, and
`BrownianMotionMethod`

. For more information, see Quasi-Monte Carlo Simulation.

## Examples

## Input Arguments

## Output Arguments

## More About

## Algorithms

This function simulates any vector-valued SDE of the following form:

$$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},{N}_{t}){X}_{t}d{N}_{t}$$

Here:

*X*is an_{t}`NVars`

-by-`1`

state vector of process variables.*B*(*t*,*X*_{t}) is an`NVars`

-by-`NVars`

matrix of generalized expected instantaneous rates of return.

is an*D*(*t*,*X*_{t})`NVars`

-by-`NVars`

diagonal matrix in which each element along the main diagonal is the corresponding element of the state vector.

is an*V*(*t*,*X*_{t})`NVars`

-by-`NVars`

matrix of instantaneous volatility rates.*dW*_{t}is an`NBrowns`

-by-`1`

Brownian motion vector.

is an*Y*(*t*,*X*_{t},*N*_{t})`NVars`

-by-`NJumps`

matrix-valued jump size function.*dN*_{t}is an`NJumps`

-by-`1`

counting process vector.

`simByEuler`

simulates `NTrials`

sample paths of
`NVars`

correlated state variables driven by
`NBrowns`

Brownian motion sources of risk over
`NPeriods`

consecutive observation periods, using the Euler
approach to approximate continuous-time stochastic processes.

Consider the process *X* satisfying a stochastic differential
equation of the form.

$$d{X}_{t}=\mu ({X}_{t})dt+\sigma ({X}_{t})d{W}_{t}$$

The attempt of including a term of *O*(*dt*) in the
drift refines the Euler scheme and results in the algorithm derived by Milstein [1].

$${X}_{t+1}={X}_{t}+\mu ({X}_{t})dt+\sigma ({X}_{t})d{W}_{t}+\frac{1}{2}\sigma ({X}_{t}){\sigma}^{/}({X}_{t})(d{W}_{t}^{2}-dt)$$

Further refining of the Euler scheme gives out a metho with a weak order 2:

$$\begin{array}{l}{X}_{t+1}={X}_{t}+\mu ({X}_{t})dt+\sigma ({X}_{t})d{W}_{t}+\frac{1}{2}\sigma ({X}_{t}){\sigma}^{/}({X}_{t})(d{W}_{t}^{2}-dt)+{\mu}^{/}({X}_{t})\sigma ({X}_{t})dI\\ +\frac{1}{2}\left(\frac{1}{2}{\sigma}^{2}({X}_{t}){\mu}^{//}({X}_{t})+\mu ({X}_{t}){\mu}^{/}({X}_{t})\right)d{t}^{2}+\left(\frac{1}{2}{\sigma}^{2}({X}_{t}){\sigma}^{//}({X}_{t})+\mu ({X}_{t}){\sigma}^{/}({X}_{t})\right)(d{W}_{t}dt-dI)\end{array}$$

where *dI* is given by the area of the triangle with base
*dt* and height *dW*.

## References

[1] Milstein, G.N. "A Method of
Second-Order Accuracy Integration of Stochastic Differential
Equations."*Theory of Probability and Its Applications*, 23,
1978, pp. 396–401.

## Version History

**Introduced in R2023b**