simu_b_m.asv
来自「用于随机模拟」· ASV 代码 · 共 50 行
ASV
50 行
%simulation of brown motion:b(t)
c=1;
N=2^10;
T=1;
b=bm(c,T,N);
% simulation of s(t)
s0=10;
sigma=0.3;
r=0.05;
for i=1:n
s(i)=s0+r*T+sigma*b(i);
end
figure(2);
plot([s0,s])
grid
xlabel('t');
ylabel('s(t)');
title('s(t)')
%simulation of positive s(t)
sp=zeros(1,n); %positive of s
for i=1:n
sp(i)=s0*exp((r-1/2*sigma^2)*t(i)+sigma*b(i));
end
figure(3);
plot([s0,sp])
%simulation of positive s(t) m times
m=10;
spm=zeros(m,n); %positive of s mant times
for i=1:m
for j=1:n
spm(i,j)=s0*exp((r-1/2*sigma^2)*t(j)+sigma*b(j));
end
end
figure(3);
plot([s0,sp(1,:)])
%plot([s0*ones(m,1),sp]')
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?