Modelling interest rate

Hi I want to model two stochastic integrals in Matlab, which is given by $x(t) = x(s) e^{-a(t-s)} + \sigma \int_s^t e^{-a(t-u)} dW_1(u)$

$y(t) = y(s) e^{-b(t-s)} + \eta \int_s^t e^{-b(t-u)} dW_2(u)$

with

$E[x(t) \vert F_s] = x(s) e^{-a(t-s)}$

$Var[x(t) \vert F_s] = \frac{\sigma^2}{2a} [1-e^{-2a(t-s)}]$

The dynamics are given by :

$dx(t) = -a x(t) dt + \sigma dW_1(t), x(0) = 0 \\ dy(t) = -by(t) dt + \eta dW_2(t), y(0) = 0$
$\\$

I want to implement this in Matlab without using the dynamics but the stochastic integral and the distribution property. I want to model paths for x(t) and y(t)

We have

$x(1) \sim N\left(x(0)e^{-at}, \frac{\sigma^2}{2a} [1-e^{-2at} \right)$

$x(2) \sim N\left(x(0)e^{-a(t-1)}, \frac{\sigma^2}{2a} [1-e^{-2a(t-1)} \right)$ .......

Knowing the distribution for each $t$, how can I model $x(t)$ for each $t$

Generally, you can approximate any SDE through simulation in discrete time. Standard schemes for this are the Euler–Maruyama, Milstein or Runge–Kutta method:

Using Euler–Maruyama, the below pseudo-code demonstrates how you could simulate one path of $x(t)$ over an interval $[0,T]$:

T  = 2       # Total length of time
dt = 0.01    # discrete time step lengths
n  = T / dt  # number of time steps
x0 = 0       # Start value of x(t)
x  = [x0]
Z  = [Array of i.i.d. Standard Normal Samples of length n]

for i = 1 to n
x[i] = x[i-1] - a * x[i-1] * dt + sigma * sqrt(dt) * Z[i]

• Thank you for your response. Isn't that just the discretization of the dynamics? I rather need a Binomial Tree, this is my guess. – SinusK Apr 12 '18 at 19:05