本文介绍了二维随机微分方程(SDE)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是第一次研究随机微分方程.我正在寻找在二维上模拟和求解随机微分方程的方法.

I am working on stochastic differential equations for the first time. I am looking to simulate and solve a stochastic differential equations in two dimensions.

模型如下:

其中:

  • p是2比1的向量:p =(theta(t); phi(t))
  • F是列向量:F =(sinθ+ Psi * cos(phi); Psi *cot(theta)* sin(phi))
  • G是2×2矩阵:G =(D 0; 0 D/sinθ)
  • Psi是一个参数,D是扩散常数
  • p is a 2-by-1 vector: p=(theta(t); phi(t))
  • F is a column vector: F=(sin(theta)+Psi* cos(phi); Psi*cot(theta)*sin(phi))
  • G is a 2-by-2 matrix: G=(D 0;0 D/sin(theta))
  • Psi is a parameter and D is the diffusion constant

我写的代码如下:

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

然后我使用以下脚本调用该函数:

Then I call the function with the following script:

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)

运行代码时,我收到以下错误消息:

When I run the code, I receive this error message:

您知道如何解决此错误吗?

Any idea how to fix this error?

推荐答案

摘自 sde :

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).

这篇关于二维随机微分方程(SDE)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 00:20