Skip to main content

Markov Matrix

A n×nn\times n matrix whose elements are non-negative and every column vector sums to 11 is known as Markov Matrix(a.k.a. stochastic matrix).
Say

A=[a11a12a1na21a22a2nan1an2ann]A=\begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1} & a_{n2} & \cdots & a_{nn} \\ \end{bmatrix}

So,

  • aij0;i,j{1,2,,n}a_{ij}\geq 0;\quad\forall i,j\in\{1,2,\cdots,n\}
  • i=0naij=1j{1,2,,n}\sum_{i=0}^{n}a_{ij}=1\quad\forall j\in\{1,2,\cdots,n\}

λ1=1\lambda_1=1

info

Markov matrix always have one of the eigenvalues =1=1.

note

Proof:

A=[a11a12a1na21a22a2nan1an2ann]A=\begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1} & a_{n2} & \cdots & a_{nn} \\ \end{bmatrix}
A1I=[a111a12a1na21a221a2nan1an2ann1]A-1\mathcal{I}=\begin{bmatrix} a_{11}-1 & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22}-1 & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1} & a_{n2} & \cdots & a_{nn}-1 \\ \end{bmatrix}

Now we apply RnR1+R2++RnR_n \leftarrow R_1 + R_2 + \cdots + R_n

AI=[a111a12a1na21a221a2ni=0nai11i=0nai21i=0nain1]A-\mathcal{I}=\begin{bmatrix} a_{11}-1 & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22}-1 & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ \sum_{i=0}^{n}a_{i1} -1 & \sum_{i=0}^{n}a_{i2} -1 & \cdots & \sum_{i=0}^{n}a_{in} -1 \\ \end{bmatrix}

And as we know that i=0naij=1j{1,2,,n}\sum_{i=0}^{n}a_{ij}=1\quad\forall j\in\{1,2,\cdots,n\}

AI=[a111a12a1na21a221a2n000]A-\mathcal{I}=\begin{bmatrix} a_{11}-1 & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22}-1 & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \cdots & 0 \\ \end{bmatrix}

So now we can see that det(AI)=0\text{det}(A-\mathcal{I})=0
So indeed λ=1\lambda=1.

Example of Markov Matrices

Assume that we have two cities AA and BB and at the end of the year we calculate the

  • Proportion of peoples remains in city AA, we denote it by pap_{a}
  • Proportion of peoples remains in city BB, we denote it by pbp_{b}
  • Proportion of peoples moved from city AA to BB, we denote it by pabp_{ab}
  • Proportion of peoples moved from city BB to AA, we denote it by pbap_{ba}

We can represent this information as a Markov Matrix (say MM).

Moved to AMoved to BFrom ApapbaFrom Bpabpb\begin{matrix} & \text{Moved to } A & \text{Moved to } B \\ \text{From } A & p_{a} & p_{ba}\\ \text{From } B & p_{ab} & p_{b}\\ \end{matrix}
M=[papbapabpb]M=\begin{bmatrix} p_{a} & p_{ba}\\ p_{ab} & p_{b}\\ \end{bmatrix}

pa+pab=1p_a + p_{ab}=1 (here we took all peoples in city AA)
pb+pba=1p_b + p_{ba}=1 (here we took all peoples in city BB)
And proportions are positive and cannot be greater then 11
So it is a Markov Matrix

Now say that at time t=kt=k.

  • Number of peoples in city AA are uAu_A
  • Number of peoples in city BB are uBu_B So at that at time t=k+1t=k+1 we can say,
[uAuB]t=k+1=[papbapabpb][uAuB]t=k\begin{bmatrix} u_{A}\\u_{B}\\ \end{bmatrix}_{t=k+1}=\begin{bmatrix} p_{a} & p_{ba}\\ p_{ab} & p_{b}\\ \end{bmatrix}\begin{bmatrix} u_{A}\\u_{B}\\ \end{bmatrix}_{t=k}

Say that we know ut=0u_{t=0} and we want to find ut=100u_{t=100} then we have to compute M100M^{100} but for large MM it's impractical to compute.
Now say that eigenvalues of MM is λ1\lambda_1 and λ2\lambda_2 and eigenvectos of MM is x1x_1 and x2x_2
So,

danger
ut=k=c1λ1kut=0+c2λ2kut=0\begin{matrix} \displaystyle \vec{u}_{t=k}=c_1\lambda_1^k\vec{u}_{t=0} + c_2\lambda_2^k\vec{u}_{t=0} \end{matrix}

Expansion with Orthogonal basis

Say that we are in nn dimensional space and q1,q2,,qn\vec{q}_1, \vec{q}_2, \cdots, \vec{q}_n are the basis for that nn dimensional space.
Here all q1,q2,,qn\vec{q}_1, \vec{q}_2, \cdots, \vec{q}_n are orthogonal
We can express any vector in this nn dimensional space as the linear combination of basis vectors.
Assume a vector vRn\vec{v}\in\mathbb{R}^n in this nn dimensional space.
we can express v\vec{v} as,
v=x1q1+x2q2++xnqn\vec{v}=x_1\vec{q}_1 + x_2\vec{q}_2 + \cdots + x_n\vec{q}_n
Ok we can express v\vec{v} as linear combination of basis vectors but we are interested in these x1,x2,,xnx_1, x_2, \cdots, x_n.

How can we compute x1,x2,,xnx_1, x_2, \cdots, x_n?
First let's see how can we get x1x_1?
IDEA: All q1,q2,,qn\vec{q}_1, \vec{q}_2, \cdots, \vec{q}_n are orthogonal so qiTqj=0;ij\vec{q}_i^T\vec{q}_j=0;\quad \forall i\neq j
so take dot product w.r.t. x1x_1.

vTq1=x1q1Tq1=1+x2q2Tq1=0++xnqnTq1=0\vec{v}^T\vec{q}_1=x_1\underbrace{\vec{q}_1^T\vec{q}_1}_{=1} + x_2\underbrace{\vec{q}_2^T\vec{q}_1}_{=0} + \cdots + x_n\underbrace{\vec{q}_n^T\vec{q}_1}_{=0}

x1=vTq1\Rightarrow x_1=\vec{v}^T\vec{q}_1

danger
xi=vTqi;i{1,2,,n}\begin{matrix} \displaystyle x_i=\vec{v}^T\vec{q}_i;\quad\forall i\in\{1,2,\cdots, n\} \end{matrix}

Say

[q1q2qn]=Q and x=[x1xn]\begin{bmatrix} \vdots & \vdots & & \vdots \\ \vec{q}_{1} & \vec{q}_{2} & \cdots & \vec{q}_{n} \\ \vdots & \vdots & & \vdots \\ \end{bmatrix}=Q \text{ and } \vec{x}=\begin{bmatrix} x_1\\ \vdots \\x_n\\ \end{bmatrix}

We can also write it in matrix form,

[q1q2qn][x1xn]=v\begin{bmatrix} \vdots & \vdots & & \vdots \\ \vec{q}_{1} & \vec{q}_{2} & \cdots & \vec{q}_{n} \\ \vdots & \vdots & & \vdots \\ \end{bmatrix} \begin{bmatrix} x_1\\ \vdots \\x_n\\ \end{bmatrix} = \vec{v}

Qx=v\Rightarrow Q\vec{x}=\vec{v}
QTQIx=QTv\Rightarrow \underbrace{Q^TQ}_{\mathcal{I}}\vec{x}=Q^T\vec{v}

danger
x=QTv\begin{matrix} \displaystyle \vec{x}=Q^T\vec{v} \end{matrix}

Fourier Series

f(x)=a01+a1cos(x)+b1sin(x)+a2cos(2x)+b2sin(2x)+f(x)=a_0 1+a_1\cos(x)+b_1\sin(x)+a_2\cos(2x)+b_2\sin(2x)+\cdots

Here instead of vectors we are using functions, so here we are computing linear combinations of functions (instead of vectors).
Here our space is \infty dimensional

  • In vector case dot product is like,

    Say v=[v1vn]\vec{v}= \begin{bmatrix} v_1\\ \vdots \\v_n\\ \end{bmatrix} and u=[u1un]\vec{u}= \begin{bmatrix} u_1\\ \vdots \\u_n\\ \end{bmatrix}
    vu=v1u1+v2u2++v1un\vec{v}\cdot\vec{u}=v_1u_1 + v_2u_2 + \cdots + v_1u_n

  • For function dot product is like,

    Vectors have some set of values like v=[v1vn]\vec{v}= \begin{bmatrix} v_1\\ \vdots \\v_n\\ \end{bmatrix}.
    But a function has a range of values like for cos(x)\cos(x) range is [0,2π][0,2\pi].
    And a dot product of two functions say ff and gg with interval [0,2π][0,2\pi] is defined as.

danger
fg=02πf(x)g(x)dx\begin{matrix} f\cdot g=\int_{0}^{2\pi}f(x)g(x)dx \end{matrix}

Here our functions are 1,cos(x),sin(x),cos(2x),sin(2x),1,\cos(x),\sin(x),\cos(2x),\sin(2x),\cdots
cos\cos and sin\sin are periodic function with period of [0,2π][0,2\pi], so 0x2π0\leq x\leq 2\pi
So we have \infty orthogonal basis.
Now we want to find a0,a1,b1,a2,b2,a_0,a_1,b_1,a_2,b_2,\cdots
First let's see how to find a1a_1?

f(x)=a01+a1cos(x)+b1sin(x)+a2cos(2x)+b2sin(2x)+f(x)=a_0 1+a_1\cos(x)+b_1\sin(x)+a_2\cos(2x)+b_2\sin(2x)+\cdots

IDEA: take dot product with function with a1a_1

f(x)cos(x)=a01cos(x)+a1cos(x)cos(x)+b1sin(x)cos(x)+a2cos(2x)cos(x)+b2sin(2x)cos(x)+02πf(x)cos(x)=02πa01cos(x)=0+02πa1cos(x)cos(x)+02πb1sin(x)cos(x)=0+02πa2cos(2x)cos(x)=0+02πb2sin(2x)cos(x)=0+f(x)\cdot\cos(x) =a_0 1\cdot\cos(x) +a_1\cos(x)\cdot\cos(x) +b_1\sin(x)\cdot\cos(x) +a_2\cos(2x)\cdot\cos(x) +b_2\sin(2x)\cdot\cos(x) +\cdots \\ \quad \\ \Rightarrow \int_{0}^{2\pi}f(x)\cos(x) =\underbrace{\int_{0}^{2\pi}a_0 1\cos(x)}_{=0} + \int_{0}^{2\pi}a_1\cos(x)\cos(x) + \underbrace{\int_{0}^{2\pi}b_1\sin(x)\cos(x)}_{=0} + \underbrace{\int_{0}^{2\pi}a_2\cos(2x)\cos(x)}_{=0} + \underbrace{\int_{0}^{2\pi}b_2\sin(2x)\cos(x)}_{=0} +\cdots \\
02πf(x)cos(x)=02πa1cos(x)cos(x)02πf(x)cos(x)=a1π02πf(x)cos(x)=a1π\Rightarrow \int_{0}^{2\pi}f(x)\cos(x) =\int_{0}^{2\pi}a_1\cos(x)\cos(x) \\ \Rightarrow \int_{0}^{2\pi}f(x)\cos(x) =a_1\pi \\ \Rightarrow \int_{0}^{2\pi}f(x)\cos(x) =a_1\pi \\

So,

danger
a1=1π02πf(x)cos(x)\begin{matrix} a_1=\frac{1}{\pi}\int_{0}^{2\pi}f(x)\cos(x) \end{matrix}

Similarly we can find rest of aia_i's