Método de Euler-Maruyama
O Método de Euler-Maruyama é uma esquema numérico desenvolvido para resolver equações diferenciais estocásticas. O nome homenageia os matemáticos Euler e Maruyama, de duas gerações completamente diferentes. O método é somente uma extensão do método de Euler, sendo assim o nome.[1]
Exemplo: crescimento populacional estocásticos
Considere a equação diferencial estocásticas:[1]
Abaixo segue o código em Matlab para resolvê-la, e logo abaixo segue algumas simulações ao lado da solução determinística.
function EulerMaruyama %This function applies the method of Euler-Maruyama for solving the %stochastic differential equation: dX(t)= rX(t)(1-X(t)/K)dt + %sigmaX(t)(1-X(t)/K)dW(t) r=0.8;%growth rate K=100;%Carrying capacity sigma=0.9;%stochasticity coefficient T=15;%time for simulation N=400;%number of steps in the grid dt=T/N;%small intervals of time x0=10;%initial condition X=x0;%state vector Xvector=x0;%list of state vectors for t=1:N %this loop shall repeat until we achieve the end of the simulation X=X + r*X*(1 - X/K)*dt + sigma*X*(1- X/K)*sqrt(dt)*randn;% the SDE Xvector=[Xvector,X];%save current simulation end mean=x0; meanlist=x0; for t=1:N %here is just the Euler method: x(t+dt)= x(t) + dt*f(x,t) % for solving dx/dt=f(x,t) mean=mean + r*mean*(1 - mean/K)*dt; meanlist=[meanlist, mean]; end time=0:dt:T; plot(time, Xvector, time, meanlist) hold on ylim([0,130]); end
A saída do código segue abaixo