Stochastic Differential Equations with jumps

3 vues (au cours des 30 derniers jours)
anas khalaf
anas khalaf le 25 Juin 2019
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

Réponses (0)

Catégories

En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by