Introduction to Markov Chains
In-class work
Math 221 Linear Algebra
October 31, 2023

T. Ratliff, Wheaton College
ratliff_thomas@wheatoncollege.edu

The stochastic matrix P for our example

As per usual, I’ll use lower case for any variable

p={{0.75, 0.15, 0.05},{0.15, 0.80,0.10},{0.10,0.05,0.85}};
p//MatrixForm

The initial state x0 and x1=p.x0

x0 = {0.50, 0.30, 0.20}
x1=p.x0
x1 //MatrixForm

A note on computing powers of matrices in Mathematica

Since (Subscript[x, n])= (P^n), we’ll want to compute powers of matrices.
BUT, we have to be careful with syntax in Mathematica. Let’s compare:

p.p //MatrixForm

p^2 // MatrixForm

These aren’t the same!
Do you see what’s happening? 
	(p^2) squares each individual entry rather than computing the matrix multiplication p.p
	
Instead, we can use the built-in command MatrixPower[p,2]

MatrixPower[p,2] //MatrixForm

There’s no real reason to use this rather than p.p, but it sure is more convenient for computing (p^20)