% MCS 320 Project 3 Markov Chains with MATLAB % % This script forms the basis for a possible solution % to the project. A complete solution consists of the % numerical values produces by this cript and the print % out of the plots of the projections of the trajectories. % % 0. Introduction % % We take a stochastic matrix A (columns sum to one) % and some starting point x0. % A = [.7 .1 .3; .2 .8 .3; .1 .1 .4] x0 = [.8; .1; .1] % % 1. Assignment One % % The following script computes the trajectory: % type trajectory.m T = trajectory(A,x0,10) % % 2. Assignment Two % % We generate trajectories starting at random points andj % make plots of the projections on the coordinate planes. % X0 = [rand(1,15)/2; rand(1,15)/2; ones(1,15)] X0(3,:) = X0(3,:) - X0(1,:) - X0(2,:) type trajplots.m subplot(3,1,1) trajplots(A,X0,40,1,2); % projection on xy-plane subplot(3,1,2) trajplots(A,X0,40,1,3); % projection on xz-plane subplot(3,1,3) trajplots(A,X0,40,2,3); % projection on yz-plane % % 3. Assignment Three % % Observing that all trajectories end at the same point, % regardless of the starting point, we compute the steady-state % vector via an eigenvalue problem, or more directly (since 1 % is always an eigenvalue) via a basis for the null space. % [v,d] = eig(A) % first method v(:,1)/sum(v(:,1)) % we need to scale nA = null(A-eye(3)) % second, more direct, method nA/sum(nA) % also here we scale