- #1

FrancescoMi

- 5

- 0

I have this dynamic:

is a Mean Reverting process. I want to simulate the sde with MATLAB but I am a beginner and I have some problems. I show you the code that I have created:

Code:

```
%% Simulazione prezzo Geometric Ornstein-Ulenbeck
clear all
clc
%Parameters
mu = 0.5;
sigma = 0.12;
eta = 1;
T = 2;
N_t = 300; %Temporal Intervals
N = 1000; %Number of Simulations
t=linspace(0,T,N_t); %Temporal line
dt=T/N_t; %Temporal increments
P_t=zeros(N,N_t);
P_t(:,1)=20; %First Price
%Model
for i=1:N
for j=2:N_t
dW = randn;
P_t(i,j) = P_t(i,j-1) + eta*(mu-log(P_t(i,j-1)))*P_t(i,j-1)*dt+sigma*P_t(i,j-1)*dW;
end
end
plot(t,P_t(1,:));
```

But I don't know if it is correct. Can you help me?