% island2.m % Markov chain model for colonization-extinction % 2/22/03 SG clear all close all tic % PARAMETERS T = 100; % number of generations to run p_col = 0.2; % probability of colonization p_ext = 0.1; % probability of extinction % TRANSITION MATRIX P = [1-p_col p_col;... p_ext 1-p_ext]; % INITIAL CONDITIONS x(1,:) = [1 0]; % island is empty initially with probability 1 % MAIN PROGRAMM for t = 2:T x(t,:) = x(1,:)* P^t; end % GRAPHICS plot(1:T,x(:,1),'d',1:T,x(:,2),'o') % plot probability of being occupied legend('Pr(empty)','Pr(occupied)') xlabel('year') ylabel('probabilities') axis([0 T 0 1]) toc % ADDITIONAL STATISTICS asym_prob_occupied = x(T,2) % asymptotic frequency of being occupied