我第一次研究随机微分方程。我正在寻找模拟和求解二维的随机微分方程。
模型如下:
dp=F(t,p)dt+G(t,p)dW(t)
在哪里:
- p 是一个 2×1 向量: p=(theta(t); phi(t))
- F是一个列向量:F=(sin(theta)+Psi* cos(phi); Psi* cot(theta)*sin(phi))
- G 是一个 2×2 矩阵:G=(D 0;0 D/sin(theta))
- Psi 是一个参数,D 是扩散常数
我写的代码如下:
function MDL=gyro_2dim(Psi,D)
% want to solve for 2-by-1 vector:
%p=[theta;phi];
%drift function
F=@(t,theta,phi) [sinth(theta)+Psi.*cos(phi)-D.*cot(theta);Psi.*cot(theta).*sin(phi)];
%diffusion function
G=@(t,theta,phi) [D 0;0 D./sin(theta)];
MDL=sde(F,G)
end
然后我使用以下脚本调用该函数:
params.t0 = 0; % start time of simulation
params.tend = 20; % end time
params.dt =0.1; % time increment
D=0.1;
nPeriods=10; % # of simulated observations
Psi=1;
MDL=gyro_2dim(Psi,D);
[S,T,Z]=simulate(MDL, nPeriods,'DeltaTime',params.dt);
plot(T,S)
当我运行代码时,我收到以下错误消息:
漂移率在初始条件下或模型尺寸不一致时无效。
知道如何解决此错误吗?