# Calculating limit law for matrix

I my notes on Markov chains, I am presented with the following matrix:

$$\mathcal{P} = \begin{bmatrix} 0.97 & 0.03 & 0 & 0 \\ 0.008 & 0.982 & 0.01 & 0 \\ 0.02 & 0 & 0.975 & 0.005 \\ 0.01 & 0 & 0 & 0.99 \end{bmatrix}$$

I am then told that the limit law is $$\vec{\pi} = (0.2715, 0.4546, 0.1826, 0.0913)$$. How was this limit law calculated?

I would greatly appreciate it if people would please take the time to clarify this.

It's called as stationary distribution and found via solving the equation: $$\pi=\pi \mathcal P$$

which is the left eigenvector of $$\mathcal P$$ corresponding to eigenvalue $$\lambda=1$$. Or, it's the usual (right) eigenvector of $$\mathcal P^T$$. After finding the eigenvector, negate the vector if elements are negative and normalise the vector such that it sums up to $$1$$. Eigenvectors are invariant under scaling.

Example:

P <- matrix(c(0.97, 0.03, 0, 0, 0.008, 0.982, 0.01, 0, 0.02,
0, 0.975, 0.005, 0.01, 0, 0, 0.99),4,4,byrow=FALSE)
r <- eigen(P)
pi = abs(r$$vectors[,r$$values==1])
pi = pi / sum(pi)
pi


Based on the procedure there may be small numerical differences.