% Number 11, section 5.1

m = [.2 .1; .8 .9];

% .2 means 20% chance of the system being in state 1 remaining in state 1
% .1 means 10% chance of the system being in state 2 but changing to state 1
% .8 means 80% chance of the system being in state 1 but changing to state 2
% .9 means 90% chance of the system being in state 2 remaining in state 2

% system in state 1 means 
v = [1;0]

% probability it will be in state 2 next is 
u = m*v
% look in 2nd component

% system with 50% chance of being in state 1 is 
v = [.5; .5]

% probability of being in state 2 at next observation
u = m*v
% look in 2nd component

%  -- - --  -- - --  -- - --  -- - --  -- - --  -- - --  -- - --  -- - --  -- - --  -- - -- -- - -- 

% Number 13, 
% 
% transition matrix
disp('a')
m = [.95 .45; .05 .55]

disp('part b')
% good today, what is the prob it will be good two days from now
v = [1;0];
u = m^2 * v
disp('look in 1st component')

pause;

disp('part c')
% bad today bad three days from now?
v = [0;1]
u = m^3 * v
disp('look in 2nd component')

pause;

disp('part d')
% bad today bad three days from now?
v = [.2; .8]
u = m * v
disp('look in 1st component')


%  -- - --  -- - --  -- - --  -- - --  -- - --  -- - --  -- - --  -- - --  -- - --  -- - -- -- - -- 

% Number 15

m = [.95 .03;
     .05 .97]

disp('part a');
% assuming total pop is constant, give population talbe over 5-year period

v = [100000;25000]

%  -- - --  -- - --  -- - --  -- - --  -- - --  -- - --  -- - --  -- - --  -- - --  -- - -- -- - -- 

m1 = [0 .5 0 .5 0 0 0]';
m2 = [1/3 0 1/3 0 1/3 0 0]';
m3 = [0 .5 0 0 0 .5 0]';
m4 = [1/3 0 0 0 1/3 0 1/3]';
m5 = [0 .25 0 .25 0 .25 .25]';
m6 = [0 0 1/3 0 1/3 0 1/3]';
m7 = [0 0 0 1/3 1/3 1/3 0]';

m = [m1 m2 m3 m4 m5 m6 m7];


