近期在学习随机微分理论,其中比较有趣的是:随机游走( S t o c h a s t i c Stochastic Stochastic P r o c e s s Process Process) 和布朗运动 B r o w n Brown Brown M o t i o n Motion Motion ,因此选出课本上的特例来进行上机实验,
程序具体和实现结果具体如下:
T = 4; %总时间区间time span
N = 1000;
dt = T/N;
t= linspace(0,T,N);
number = input('请输入你的学号:','s');
sigma = 0.3;r = 0.1;S0 = 1;%参数初始化
for i =1:N
W = [0,cumsum(dt^2.*randn(1,N))];
S = S0*exp((r-sigma^2/2)*t(i)+sigma*W);
end
plot(0:N,S);
hold on
for i =1:N
W1 = [0,cumsum(dt^2.*randn(1,N))];
S1 = S0*exp((r-sigma^2/2)*t(i)+sigma*W1);
end
plot(0:N,S1,'r-');
hold on
for i = 1:N
W2 = [0,cumsum(dt^2.*randn(1,N))];
S2 = S0*exp((r-sigma^2/2)*t(i)+sigma*W2);
end
plot(0:N,S2,'g-');
hold on
for i =1:N
W3 = [0,cumsum(dt^2.*randn(1,N))];
S3 = S0*exp((r-sigma^2/2)*t(i)+sigma*W3);
end
plot(0:N,S3,'b-');
legend('The First','The Second','The Third','The Forth' );
title(gca,['The Geometric Brown motion ',num2str(number)]);
xlabel('The length of steps ');
ylabel('Primary asset price');
其中还可以根据修改 t i t l e title title 的名称,请在转载中注明出处,相互借鉴学习。
h t t p s : / / b l o g . c s d n . n e t / E d w o r d a d r a / a r t i c l e / d e t a i l s / 110748578 https://blog.csdn.net/Edword_adra/article/details/110748578 https://blog.csdn.net/Edwordadra/article/details/110748578