⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simu_b_m.m

📁 用于随机模拟
💻 M
字号:
%simulation of brown motion:b(t)
c=1;
N=2^10;
T=1;
b=bm(c,T,N);

% simulation of s(t)
c=1;
N=2^10;
T=1;
b=bm(c,T,N);

t=1/N:T/N:T;
s0=10;
sigma=0.3;
r=0.05;
s=zeros(1,N);
for i=1:N
    s(i)=s0+r*T+sigma*b(i);
end
figure
plot([0,t],[s0,s])
grid
xlabel('t');
ylabel('s(t)');
title('s(t)')

%simulation of positive s(t)
c=1;
N=2^10;
T=1;
b=bm(c,T,N);

t=1/N:T/N:T;
s0=10;
sigma=0.3;  %sigma=0.2,0.4
r=0.05;
s=zeros(1,N);    
for i=1:N
    s(i)=s0*exp((r-1/2*sigma^2)*t(i)+sigma*b(i));  % s is positive
end
figure;
plot([s0,s])






⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -