How to plot a SDE $dx(t)=Ax(t)dt+Bx(t)dW(t) $ using Matlab, and how will the graph look like?

966 Views Asked by At

Could you please provide a full Matlab programme (which can be copied and pasted directly) that can plot the solution to the stochastic differential equation (SDE) $dx(t)=Ax(t)dt+Bx(t)dW(t)$, (where $x(t)$ is plotted as vertical axis, and time t is plotted as horizontal axis), where both A and B are given 2*2 matrices(please give some appropriate numbers to fix matrix A and B for programming), W(t) is Ito type Brownian motion (BM). I am very curious about how to set the BM with Matlab. Must I use any package or tool box to handle this issue? In addition, shall we make any assumption about the setting of BM in Matlab, especially for its variance? Shall we set the variance to a fixed number like 1, or bigger number like 100 or 1000? Thank you very much.

1

There are 1 best solutions below

11
On BEST ANSWER

Every time you rum the program you will see a new figure (note that)

first thing you must do is "discretization"

for example see below:

$$dx_t=a.x_t dt+ b.x_t.dw_t\\ \Delta x_t=a.x_t .\Delta t +b.x_t.\Delta W_t \\ x_{i+1}-x_i=a.x_i.\Delta t_i +b.x_i.\Delta W_{t_i}\\ $$ if partitions are equidistant ... $$\Delta t_t=\Delta t=\frac{T-t_0}{n}\\\Delta W=\sqrt{\Delta t}*randn$$ so you can code this form $$x(i+1)-x(i)=a*x(i)*\Delta t +b*x(i)*\sqrt{\Delta t}*randn\\ $$

%dx(t)=ax(t)dt+bx(t)dW(t)  
%for exaple a=2, b=0.5  
t0=0;        %begin time
T=1;         %terminal time
n=100;       %number of steps
dt=(T-t0)/n  %set delta t
a=2;         %input a
b=0.5;       %input b
dw=zeros(1,n);  
axis=[t0+dt:dt:T];
x=zeros(1,n);
x(1)=2;      %x(1)=x0=2  initial condition

for k=2:n
  dw(k)=sqrt(dt)*randn;  
  x(k)=x(k-1)+a*x(k)*dt +b*x(k-1)*dw(k-1);
end

grid on  
hold on 
plot(axis,x)

enter image description here this is 1st run of program