<< esvaroptim Financial module evt >>

Financial module >> Financial module > euler

euler

Numerically solves a system of stochastic differential equation (by using the Euler discretization)

SYNOPSIS

x=euler(drift,diffusion,dt,T,x0,t0);

Description

The function numerically solves a system of stochastic differential equations in the following form:

dx(1) = drift_1(x(1),x(2),..,x(n),t) dt + diffusion_1(x(1),x(2),..,x(n),t) dW

dx(2) = drift_2(x(1),x(2),..,x(n),t) dt + diffusion_2(x(1),x(2),..,x(n),t) dW

...

dx(n) = drift_n(x(1),x(2),..,x(n),t) dt + diffusion_n(x(1),x(2),..,x(n),t) dW

Please note that dW (the differential form of a Wiener process) could be a vector and, accordingly, each "diffusion" term could be a vector itself. All the elements of dW are assumed to be independent.

Parameters

drift
this is a string containing a column vector of the functional forms of drift_1, drift_2 and so on. The variables "x" and "t" must be named exactly "x" and "t" and if there are more than one "x" the values must be named "x(1)", "x(2)", and so on.
diffusion
This is a string containing a matrix which have as many raws as x's and as many columns as the elements of vector dW (containing the so-called risk sources). Thus, if there are three stochastic variables (i.e. x(1), x(2), and x(3)) driven by two risk sources (i.e. dW(1) and dW(2)) the "diffusion" is a 3x2 matrix
dt
time unit of measure: if data are in annual form (like returns, for instance) but have daily frequency, then dt=1/250 (since there are 250 working day in one year)
T
number of periods during which the stochastic differential equations must be solved (if T=2 years, and dt=1/250, then the function computes 500 values)
x0, t0
initial values for the variables "x" and for time "t". These are the values the Euler algorithm must start from. x0 must be a column vector, while t is a scalar

Output

x
matrix whose columns contain the series of simulated variable "x"

Example

Let us assume a stochastic mean reverting process for the interest rate "r":

dr = 0.1 (b - r) dt + 0.056 sqrt(r) dWr

where the parameter "b" is another mean reverting process

db = 0.2 (0.05 - b) dt + 0.01 sqrt(b) dWb

In order to simulate two years of daily data starting from 0.04 for both "r" and "b" at time t=0, we must give the following command (we assume x(1)=r and x(2)=b)

-->drift='[0.1*(x(2)-x(1)); 0.2*(0.05-x(2))]';

-->diffusion='[0.056*sqrt(x(1)),0;0,0.01*sqrt(x(2))]';

-->x=euler(drift,diffusion,1/250,2,[0.04;0.04],0)

With command "plot(x)" one can see both stochastic processes

Authors

Francesco Menoncin - Brescia University - 2010

See Also


<< esvaroptim Financial module evt >>