% logist_stoch.m uses the Euler method to solve a stochastic logistic % equation. Adapted from http://www-math.bgsu.edu/~zirbel/sde/ T=20; % maximum time to go to h=0.1; % time step N=ceil(T/h); % number of steps to take r=3.3; K=1.4; t=zeros(N,1); % prepare a place to store times z=zeros(N,1); % prepare a place to store locations t(1) = 0; % initial time z(1) = 1; % initial location for i=1:N % take N steps t(i+1) = t(i) + h; z(i+1) = z(i)+(r+2*rand)*z(i)*(1-z(i)/(K+0.2*rand))*h; end; %clf figure plot(t,z); axis([0 T (min(z)) (max(z)+1)]); % set axis limits title('Stochastic logistic growth');