\documentclass{article}

% Packages required to support encoding
\usepackage{ucs}
\usepackage[utf8x]{inputenc}

% Packages required by code


% Packages always used
\usepackage{hyperref}
\usepackage{xspace}
\usepackage[usenames,dvipsnames]{color}
\hypersetup{colorlinks=true,urlcolor=blue}

\input{preamble.tex}


\begin{document} 
\hypertarget{lecture_8_notes_1}{}\section*{{Lecture 8 notes}}\label{lecture_8_notes_1}

\hypertarget{scribed_by_ryan_rossi_2}{}\subsubsection*{{Scribed by Ryan Rossi}}\label{scribed_by_ryan_rossi_2}

\hypertarget{adjacency_matrix_facts_3}{}\subsection*{{Adjacency Matrix Facts}}\label{adjacency_matrix_facts_3}

$\mA$ is an adjacency matrix for an unweighted graph without self-loops. Also known as a simple graph in this class, but other sources may have conflicting definitions.

\begin{itemize}%
\item $\mA\ones$ gives the \emph{out-degree} of all vertices
\item $\mA^T\ones$ gives the \emph{in-degree} of all vertices

\end{itemize}
\textbf{Theorem.} $[\mA^k]_{i,j} = \text{ \# of paths between i and j of length k. }$

\textbf{Proof.}

If $k=1$, then the paths of length 1 are exactly the edges.

If $k=2$,

\begin{displaymath}
[\mA^2]_{ij} = \sum_{r}\biggl[A_{ir}A_{rj} =
\begin{cases}
   1 & i \rightarrow r \rightarrow j  \\
   0       & \text{else }
  \end{cases}
  \biggr].
\end{displaymath}
This equation counts the number of vertices $r$ such that there is a path from $i$ to $r$ to $j$. This is a length $2$ path.

For k=3, the case is similar

\begin{displaymath}
[\mA^3]_{ij} = \sum_{r,s}\biggl[A_{ir} A_{rs} A_{sj} =
\begin{cases}
   1 &  i \rightarrow r \rightarrow s \rightarrow j  \\
   0       & \text{else }
  \end{cases}
  \biggr].
\end{displaymath}
This equation counts vertices $r$ and $s$ such that a path $i$ to $r$ to $s$ to $j$ exists. This is a path of length 3.

For general $k$, we proceed inductively. Assume it works for $k = \ell$,

\begin{displaymath}
[\mA^{(\ell+1)}]_{ij} = 
[\mA \mA^\ell]_{ij} = 
\sum_{r} 
  \biggl[ 
    A_{i,r} 
    [\mA^{\ell}]_{r,j} 
    = \begin{cases} [\mA^{\ell}]_{r,j} & i \rightarrow r \rightarrow \cdots \rightarrow j \\
0 & \text{otherwise } \end{cases} \biggr].
\end{displaymath}
Now, we are counting the vertices $r$ that prepend a length $\ell$ path from $i$ to $r$, and then $r$ to $j$ in $\ell$ steps. Again, this is exactly the number of paths from $i$ to $j$ in $\ell+1$ steps.

\textbf{End proof.}

Note that the above formulation counts the number of paths, which can repeat both vertices and edges.

\hypertarget{counting_triangles_4}{}\subsection*{{Counting Triangles}}\label{counting_triangles_4}

Suppose $\mA$ is an adjacency matrix for an undirected simple graph, then

\begin{displaymath}
\diag(\mA^3) = \vt
\end{displaymath}
gives twice the number of triangles around the $i$th vertex in the $i$th entry of $\vt$:

\begin{displaymath}
t_i = [\mA^3]_{i,i} = \text{ twice the triangles around $i$ }.
\end{displaymath}
This occurs because a triangle is exactly a path of length $3$.

The count of all triangles is given by,

\begin{displaymath}
\trace(\mA^3) = \sum_{i=1}^{n}[\mA^3]_{ii}
\end{displaymath}
which overcounts the number of triangles in the graph by a factor of 6.

\hypertarget{estimating_the_trace_via_eigenvalues_5}{}\subsubsection*{{Estimating the trace via eigenvalues}}\label{estimating_the_trace_via_eigenvalues_5}

The trace can be computed by summing the eigenvalues, therefore the number of triangles is given by,

\begin{displaymath}
\trace(\mA^3) = \sum_{i=1}^{n}\lambda^3_i.
\end{displaymath}
Assuming rapid decay in the eigenvalues such that

\begin{displaymath}
\lambda_1^3 \ge \lambda_2^3 \ge \cdots \ge \lambda_s^3 \gg \lambda_{s+1}^3 \ge \cdots \lambda_n^3
\end{displaymath}
then a reasonable estimate of the trace is

\begin{displaymath}
\trace(\mA^3) \approx \; \sum_{i=1}^{s}\lambda^3_i.
\end{displaymath}
Tsourakakis worked on this idea in ``{}Fast Counting of Triangles in Large Real Networks without Counting: Algorithms and Laws''{}

\hypertarget{randomized_trace_estimators_6}{}\subsubsection*{{Randomized trace estimators}}\label{randomized_trace_estimators_6}

The numberof triangles can also be estimated,

\begin{displaymath}
\trace(\mA^3) = \frac{1}{n} E\biggl[ \frac{\vx^TA^3\vx}{\vx^T\vx}\biggr]
\end{displaymath}
where $E$ is the expectation and $\vx \sim  N(0,1)$ is a random vector with random normals. Haim Avron and Sivan Toledo worked on some new analysis for these estimators in a recent paper: Randomized algorithms for estimating the trace of an implicit symmetric positive semi-definite matrix. Journal of the ACM, 58:8:1-8:34, April 2011.

\hypertarget{markov_chains_7}{}\section*{{Markov Chains}}\label{markov_chains_7}

The motivation/introduction to Markov chains was presented as slides which can be found at: \url{http://www.cs.purdue.edu/homes/dgleich/nmcomp/slides/lecture-7.pdf}

A Markov chain is an instance of a stochastic process. A stochastic process is a sequence of random variables,

\begin{displaymath}
X_0, X_1, X_2, ... \; \Leftrightarrow \;  (X_n \geq 0)
\end{displaymath}
This is a discrete time stochastic process (in contrast to continuous). The possible values of $X_i \in \mathcal{S}$ denotes the state space of the chain.

\textbf{Example} Consider a sequence of coin flips drawn from a random variable,

\begin{displaymath}
X_n \sim 
\begin{cases}
   H & \text{w/ prob } 0.55  \\
   T       & \text{w/ prob } 0.45 
  \end{cases}
\end{displaymath}
This is an instance of an \emph{i.i.d} chain (independent identically distributed). The state space, $\mathcal{S} = \{H,T\}$

\textbf{Example}

\begin{displaymath}
X_{n+1} = 
\begin{cases}
  X_{n+1} & \text{w/ prob } 0.5  \\
  X_{n-1}       & \text{w/ prob } 0.5 
  \end{cases}
\end{displaymath}
The above is known as a random-walk process on integers, $\mathcal{S} = \mathbb{Z}$

\hypertarget{formal_definition_8}{}\subsection*{{Formal Definition}}\label{formal_definition_8}

More formally, a Markov chain is a stochastic process where

\begin{displaymath}
\probof{X_{n+1} = S_i \mid X_0, X_1,...,X_n} = \probof{X_{n+1} = \mathcal{S}_i \mid X_n }
\end{displaymath}
We focus mostly on Time homogeneous Markov chains (or stationary Markov chains).

\begin{displaymath}
\probof{\mX_{n+1} = S_j \mid \mX_n = \mathcal{S}_i}
\end{displaymath}
where the probability of the transition is independent of n, the current ``{}time-step''{} of the chain.

\hypertarget{random_walks_9}{}\subsection*{{Random Walks}}\label{random_walks_9}

A traditional definition of random-walks from a well-known probability textbook:

\begin{displaymath}
S_n = \sum_{i=1}^n \mX_i, \text{ where } (X_n, n \geq 0) \text{ is iid. }
\end{displaymath}
This definition seems hard to adapt for things like random walks on graphs.

For this class, we will use the terms ``{}random walk''{} and ``{}Markov chain''{} almost interchangeably. The distinction between them will be mainly one of semantics. A Markov chain is a probabilistic construct, a random walk is a topological construct. For instance, for each Markov chain, we can associate a directed graph:

\begin{displaymath}
V = \mathcal{S}
\end{displaymath}
\begin{displaymath}
E = \{ (S_i, S_j) \mid \probof{ X_{n+1} = S_j \mid X_{n} = S_i } > 0\}.
\end{displaymath}
For this reason, writing down the transition graph of a random walk is a convenient way to describe the non-zero transition probabilities of a Markov chain.

\begin{verbatim}Need a figure here illustrating the relationship\end{verbatim}
\textbf{Uniform random walk} Given a graph, a uniform random walk is a Markov chain where the probability of making any transition is uniform over all possible choices. That is, when the chain/walk is at a state/vertex, then the next state /vertex is picked uniformly among all edges from the vertex.

\hypertarget{stochastic_matrices_10}{}\subsection*{{Stochastic Matrices}}\label{stochastic_matrices_10}

$(X_n, n \geq 0)$ is a Markov chain; index the states in $\mathcal{S}$ (assumed to be a finite set in this class),

\begin{displaymath}
1,2,...,|\mathcal{S}|
\end{displaymath}
Then the transition matrix for $X$ is:

\begin{displaymath}
\mP_{ij} = \probof{\mX_{n+1} = \mathcal{S}_j \mid \mX_n = \mathcal{S}_i}
\end{displaymath}
The following properties must also hold for stochastic matrices (from probability):

\begin{displaymath}
\sum_{j} \mP_{ij} = 1
\end{displaymath}
Formally, a stochastic matrix is non-negative, with rows that sum to 1.

\begin{displaymath}
\mP_{ij} \geq 0,
\end{displaymath}
\begin{displaymath}
\mP\ones = \ones \; \Leftrightarrow \; \sum_{j} P_{ij} = 1
\end{displaymath}
The above, $\mP\ones$, sums the probabilities in each row, and therefore $\ones$ should be a vector of all 1'{}s.

Besides row stochastic matrices, there are also column stochastic matrices,

\begin{displaymath}
\mP_{ij} \geq 0, \mP^T\ones = \ones \; \Leftrightarrow \; \sum_{i}\mP_{ij} = 1
\end{displaymath}
There are also doubly stochastic matrices (very special type of mathematical object). They are characterized by the \href{http://en.wikipedia.org/wiki/Doubly_stochastic_matrix}{Birkhoff-von Neumann theorem}.

\hypertarget{state_properties_11}{}\subsection*{{State Properties}}\label{state_properties_11}

A state in a Markov chain can have a few different properties.

\hypertarget{absorbing_state_12}{}\subsubsection*{{Absorbing State.}}\label{absorbing_state_12}

A state is called absorbing if it is impossible to leave this state. Therefore, the state $i$ is absorbing if $\mP_{ii} = 1$ and $\mP_{ij} = 0$ for $i \not= j$.

For instance, consider the two state diagram where $\mathcal{S}_1 \; \rightarrow \; \mathcal{S}_2$ given by the transition matrix (stochastic row matrix),

\begin{displaymath}
\mP = \bmat{ 0 & 1 \\
                0 & 1 }.
\end{displaymath}
Thus, a random-walk on this state diagram would always end up at $\mathcal{S}_2$ (acting as a sink; absorbing) with 0 probability of transitioning to $\mathcal{S}_1$.

\hypertarget{transient_state_13}{}\subsubsection*{{Transient State}}\label{transient_state_13}

In the previous example, $\mathcal{S}_1$ is a perfect example of a transient state. Informally, a transient state is one for which the Markov chain may not return. That is, given that the chain was at state $i$, then the probability that the chain is ever at state $i$ again is less than 1. This is a little tricky to formalize in terms of probability. We'{}ll formalize it shortly in terms of the strongly connected component structure of the Markov chain as a random walk on a graph.

\hypertarget{recurrent_state_14}{}\subsubsection*{{Recurrent state}}\label{recurrent_state_14}

The opposite of a transient state is a recurrent state! This is a state that the chain will always revisit. A very simple example is the absorbing state. However, an ergodic state is simply one that the chain will always revisit in the future. Again, this concept is easiest to formalize in terms of the strong component structure, so we'{}ll delay the formality.

\hypertarget{periodic_state_15}{}\subsubsection*{{Periodic state}}\label{periodic_state_15}

A periodic state is a special type of recurrent state which can only be revisited on a specific period. Consider a simple directed cycle between three vertices:

\begin{verbatim}Insert a picture here\end{verbatim}
Then a periodic state will be

\hypertarget{an_erdodic_state_16}{}\subsubsection*{{An erdodic state}}\label{an_erdodic_state_16}

A recurrent state that isn'{}t periodic is called ergodic. These are also called ``{}aperiodic''{}.

\hypertarget{relationship_to_strongly_connected_components_17}{}\subsubsection*{{Relationship to strongly connected components}}\label{relationship_to_strongly_connected_components_17}

In the second on random walks, we mentioned that every Markov chain can be considered as a directed graph where the states are vertices and the non-zero transition probabilities are the edges. By analyzing the structure of the strongly connected components of this graph, we can easily formalize the definition of the types of states.

Recall that a strongly connected component of a directed graph is a set of vertices where there are directed paths between all pairs of vertices. That is, if $i$ and $j$ are in a strong component, then there is a directed path from $i$ to $j$ and $j$ to $i$.

\begin{verbatim}Insert a picture of a graph and its strong components\end{verbatim}
We can also define a component graph, which is a new graph where each strong component in a single vertex, and the edges reflect ways of moving between the strong components. Note that this graph \emph{must be acyclic}. Any cycle would have produced a larger strong component. Consequently, the component graph is a directed acyclic graph!\newline The terminal nodes in this dag (those at the end of the dag) are recurrent states. The other nodes in the dag correspond to transient components, and thus, identify the transient states. To see why this is the case, consider that for any of these transient components, there is a non-zero probability of leaving the component. Once a walk leaves the component, the walk cannot return. Hence, the probability that the walk will ever visit ``{}that transient vertex''{} again is less than 1.

The absorbing states are those terminal components with exactly one state. The periodic states are those where the greatest common divisor of the

\hypertarget{a_stochastic_matrix_permutation_18}{}\subsection*{{A stochastic matrix permutation}}\label{a_stochastic_matrix_permutation_18}

The strongly connected component structure of the the Markov chain means that we can permute the stochastic matrix for the Markov chain into a particular form.

Let $T_1, \ldots, T_k$ be the transient components. Let $R_1, \ldots, R_m$ be the recurrent components that aren'{}t absorbing and let $A$ represent the set of absorbing vertices.

\begin{displaymath}
\mP = \bmat{\mP_{T_1}	&	\mP_{T_1,T_2}	&	\cdots	&	\mP_{T_1,T_k}	&	\mP_{T_1,R_1}	&	\mP_{T_1,R_2}	&	\cdots	&	\mP_{T_1,R_m}	&	\mP_{T_1,A}	\\
	&	\mP_{T_2}	&	\cdots	&	\mP_{T_2,T_k}	&	\mP_{T_2,R_1}	&	\mP_{T_2,R_2}	&	\cdots	&	\mP_{T_k,R_m}	&	\mP_{T_1,A}	\\
	&		&	\ddots	&	\vdots	&	\vdots	&	\vdots	&	\ddots	&	\vdots	&	\vdots	\\
	&		&		&	\mP_{T_k}	&	\mP_{T_k,R_1}	&	\mP_{T_k,R_2}	&	\cdots	&	\mP_{T_k,R_m}	&	\mP_{T_k,A}	\\
	&		&		&		&	\mP_{R_1}	&	0	&	\cdots	&	0	&	0	\\
	&		&		&		&		&	\mP_{R_2}	&	\ddots	&	0	&	0	\\
	&		&		&		&		&		&	\ddots	&		&	\vdots	\\
	&		&		&		&		&		&		&	\mP_{R_m}	&		\\
	&		&		&		&		&		&		&		&	\mI	\\
}
\end{displaymath}
Note that there are no transitions out of the recurrent states components.


\end{document}
