x0=0;
T=1;
M=100;%number of periods
N=1000;%number of simulations
dt=T/M;%length of time step
shocks=randn(N,M);
x=zeros(N,M+1);
x(:,1)=x0;
for j=1:M
x(:,j+1)=x(:,j)+(-x(:,j).^3+48*x(:,j)+100)*dt+sqrt(dt)*shocks(:,j);
end
plot(mean(x))
以上是matlab codes。参数值你可以自己调。
x0=0;
T=1;
M=100;%number of periods
N=1000;%number of simulations
dt=T/M;%length of time step
shocks=randn(N,M);
x=zeros(N,M+1);
x(:,1)=x0;
for j=1:M
x(:,j+1)=x(:,j)+(-x(:,j).^3+48*x(:,j)+100)*dt+sqrt(dt)*shocks(:,j);
end
plot(mean(x))