Numerically solves a system of stochastic differential equation (by using the Euler discretization)
x=euler(drift,diffusion,dt,T,x0,t0);
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.
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
Francesco Menoncin - Brescia University - 2010