Stochastic Differential Equations with jumps

6 views (last 30 days)
Hello every one, I'm working on Geometric Brownian motion, i bulid my code but it doesnt work as i want !!!! the two processes X and Y shouldnt cross each other, when the are about to meet should bounce away from each other. thats what i want to get. thanks in advance, this is my code below
clear variables
randn('state', 100)
mu = -2; mu2 = 2; sigma=1; sigma2=1;
Xzero = 50; Yzero =10;
Delta = 0.005;
p = 10; N = 2^p; T = 1; dt = 1/N; n=1:N;
% rnd = randn(1,N);
dW = sqrt(dt)*randn(1,N); % Brownian increments
% dW = sqrt(dt)*rnd; % Brownian increments
W = cumsum(dW); % discretized Brownian path
Alpha = mu*([dt:dt:T])+sigma*W;
M = 2^p; S = 1; ds = 1/M;
dW2 = sqrt(ds)*randn(1,M); % Brownian increments2
% dW2 = sqrt(ds)*rnd; % Brownian increments2
W2 = cumsum(dW2);
Betta = mu2*([ds:ds:S])+sigma2*W2;
A = log(Xzero)+ Alpha; B = log(Yzero)+ Betta;
H=(-2*(n-1)*Delta);
D = (A-B); L =(n-1)*Delta;
X=zeros(size(n)); Y=X;
for ii=n
% L(ii) =sum(n-1)*Delta;
%L(ii) =(ii-1)*Delta;
if D(ii)>=H(ii)
Bounce =0;
else
Bounce=L(ii);
end
X(ii) = Xzero*(exp(Alpha(ii)+Bounce));
Y(ii) = Yzero*(exp(Betta(ii)-Bounce));
end
plot([0:dt:T],[Xzero,X],'b-'); hold on
plot([0:ds:S],[Yzero,Y],'r-'); hold off
xlabel('Time')
ylabel('position')
untitled2.jpg

Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!