% island1.m % Markov chain model for colonization-extinction % 2/22/03 SG clear all close all % PARAMETERS T = 500; % number of generations to run p_col = 0.2; % probability of colonization p_ext = 0.1; % probability of extinction % INITIAL CONDITIONS X(1) = 0; % island is empty initially % MAIN PROGRAMM for t = 1:T if X(t)==0 % if island is empty if rand < p_col % colonization with probability p10 X(t+1)=1; else % no change otherwise X(t+1)=0; end else % if island is colonized if rand < p_ext % extinction with probability p01 X(t+1)=0; else % no change otherwize X(t+1)=1; end end end % GRAPHICS plot(X,'o') xlabel('year') ylabel('island state X') axis([0 T -.1 1.1]) % ADDITIONAL STATISTICS X_mean = mean(X) % overall frequency of being occupied