随机微分方程(SDE)数值解的例子?

计算科学 数值分析 随机
2021-12-23 13:23:05

我想模拟一个非线性随机微分方程

dXt=f(Xt)dt+g(Xt)dBt
在哪里f,gC(Rn,R)Bt是一维标准布朗运动。我怎样才能通过 MATLAB 做到这一点?

类似方程的良好模拟文件可能会有所帮助。

2个回答

查看Des Higham的这篇论文和SDETools MATLAB 工具箱

dxt=2xtdt+xtdwtx0=1

% EM Euler-Maruyama method on linear SDE  
%  
% SDE is dX = lambda*X dt + mu*X dW, X(0) = Xzero,  
% where lambda = 2, mu = 1 and Xzero = 1.  
%  
% Discretized Brownian path over [0,1] has dt = 2^(-8).  
% Euler-Maruyama uses timestep R*dt.  

state=randn(100)  
lambda = 2;  
mu = 1;  
Xzero = 1;   % problem parameters  
T = 1;  
N = 2^8;  
dt = 1/N;  
dW = sqrt(dt)*randn(1,N); % Brownian increments  
W = cumsum(dW); % discretized Brownian path  
Xtrue = Xzero*exp((lambda-0.5*mu^2)*([dt:dt:T])+mu*W);  
plot([0:dt:T],[Xzero,Xtrue]), hold on  
R = 4;  
Dt = R*dt;  
L = N/R; % L EM steps of size Dt = R*dt  
Xem = zeros(1,L); % preallocate for efficiency  
Xtemp = Xzero;  
for j = 1:L  
Winc = sum(dW(R*(j-1)+1:R*j));  
Xtemp = Xtemp + Dt*lambda*Xtemp + mu*Xtemp*Winc;  
Xem(j) = Xtemp;  
end  
plot([0:Dt:T],[Xzero,Xem]), hold off