且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

二维随机微分方程(SDE)

更新时间:2022-06-26 23:59:14

摘自 sde :

用户定义的漂移率函数,用F表示. DriftRate是一个函数,当使用两个输入进行调用时,该函数将返回NVARS by-1漂移率向量:
-实值标量观察时间t.
-一个NVARS by-1状态向量Xt.

User-defined drift-rate function, denoted by F. DriftRate is a function that returns an NVARS-by-1 drift-rate vector when called with two inputs:
- A real-valued scalar observation time t.
- An NVARS-by-1 state vector Xt.

Diffusion功能提供了类似的规范.但是,您将状态向量的元素作为标量传递,因此具有三个而不是两个输入.您可以尝试将模型创建功能更改为:

A similar specification is provided for the Diffusion function. However, you're passing in the elements of your state vector as scalars and thus have three, rather than two, inputs. You can try changing your model creation function to:

function MDL=gyro_2dim(Psi,D)
% State vector: p = [theta;phi];
F = @(t,p)[sin(p(1))+Psi.*cos(p(2))-D.*cot(p(1));
           Psi.*cot(p(1)).*sin(p(2))];            % Drift
G = @(t,p)[D 0;
           0 D./sin(p(1))];                       % Diffusion
MDL = sde(F,G);
MDL.StartTime = 0;   % Set initial time
MDL.StartState = ... % Set initial conditions

我也将sinth(theta)更改为sin(p(1)),因为没有sinth功能.我无法测试此功能,因为我没有财务"工具箱(很少这样做).

I also changed sinth(theta) to sin(p(1)) as there is no sinth function. I can't test this as I don't have the Financial toolbox (few do).