matlab中提取微分方程某点的值,从随机微分方程解中提取某些参数的值
我在matlab中求解隨機(jī)微分方程。
例如:
考慮隨機(jī)微分方程
dx=k A(x,t)dt+ B(x,t)dW(t)
其中k是常數(shù),A和B是函數(shù),dW(t)是Wiener過程。
我在[0,20]中為所有t繪制解決方案。我們知道dW(t)是隨機(jī)生成的。我的問題是:我想知道特定的t值和特定子區(qū)間的A(x,t),B(x,t),dW(t)的值,比如說[3,6]。我可以使用Matlab中的哪個(gè)命令?
以下是我根據(jù)D.Higham的論文使用的代碼:
clear all
close all
t0 = 0; % start time of simulation
tend = 20; % end time
m=2^9; %number of steps in each Brownian path
deltat= tend/m; % time increment for each Brownian path
D=0.1; %diffsuion
R=4;
dt = R*deltat;
dW=sqrt( deltat)*randn(2,m);
theta0=pi*rand(1);
phi0=2*pi*rand(1);
P_initial=[ theta0; phi0];
L = m/ R;
pem=zeros(2,L);
EM_rescale=zeros(2,L);
ptemp=P_initial;
for j=1:L
Winc = sum(dW(:,[ R*(j-1)+1: R*j]),2);
theta=ptemp(1);% updating theta
phi=ptemp(2); % updating phi
%psi=ptemp(3); % updating psi
A=[ D.*cot(theta);...
0];% updating the drift
B=[sqrt(D) 0 ;...
0 sqrt(D)./sin(theta) ]; %% updating the diffusion function
ptemp=ptemp+ dt*A+B*Winc;
pem(1,j)=ptemp(1);%store theta
pem(2,j)=ptemp(2);%store phi
EM_rescale(1,j)=mod(pem(1,j),pi); % re-scale theta
EM_rescale(2,j)=mod(pem(2,j),2*pi); % re-scale phi
end
plot([0:dt:tend],[P_initial,EM_rescale],'--*')
假設(shè)我想知道每個(gè)特定時(shí)間點(diǎn)或任何時(shí)間間隔的所有參數(shù)(包括隨機(jī):布朗)。怎么做?
總結(jié)
以上是生活随笔為你收集整理的matlab中提取微分方程某点的值,从随机微分方程解中提取某些参数的值的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【SDE】随机微分方程(1)
- 下一篇: 用计算机模拟宇宙,科学家尝试利用计算机模