stationary

# stationary - function v = stationary(P This is a MATLAB...

This preview shows page 1. Sign up to view the full content.

function v = stationary(P) % % This is a MATLAB function that calculates the stationary probability vector v % of a Markov chain transition matrix P, i.e., we solve v = v*P . % We assume the existence of a unique stationary vector. % For a finite-state Markov chain, the condition is that the chain be irreducible. % % There is a shorter program in stat.m % This program uses the inverse of a square matrix. % For a square matrix A, inv(A)*A = I, where I is the identity matrix (1's on the diagonal, 0's elsewhere). % The other program stat.m uses the solve functions b/A and A\b % % % We input the matrix P when we call the function. % First find the number n of rows in the transition matrix P. s = size(P); n = s(1); % % There is one redundant equation in the n equations v = vP. % We fill gap by using the fact that v(1) + . .. + v(n) = 1. % We eliminate redundant equation by replacing last column of P with ones. % That keeps the matrix square.
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 01/16/2012 for the course IEOR 4106 taught by Professor Whitward during the Spring '11 term at Columbia College.

Ask a homework question - tutors are online