{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true,
"tags": [
"remove_cell"
]
},
"outputs": [],
"source": [
"# HIDDEN\n",
"from datascience import *\n",
"from prob140 import *\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"plt.style.use('fivethirtyeight')\n",
"%matplotlib inline\n",
"import math\n",
"from scipy import stats\n",
"from scipy import misc"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Deconstructing Chains ##"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let $S$ be a finite or countably infinite set of states. Any stochastic matrix with rows and columns indexed by $S$ is the transition matrix of some Markov chain with state space $S$. The transition behaviors of Markov chains are thus as varied as the matrices. It is helpful to set up terminology to discuss some of these behaviors."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Communication ###\n",
"If it is possible for the chain to get from state $i$ to state $j$, we say that *$i$ leads to $j$* and we write $i \\rightarrow j$. Usually you can decide whether $i$ leads to $j$ just by examining the transition diagram of the chain. As a formal definition, $i \\rightarrow j$ if:\n",
"- There is a path of positive probability that starts at $i$ and ends at $j$.\n",
"- Equivalently, there is some $n > 0$ such that $P_n(i, j) > 0$.\n",
"\n",
"We say that *$i$ communicates with $j$* if $i \\rightarrow j$ and $j \\rightarrow i$. In that case we write $i \\leftrightarrow j$.\n",
"\n",
"If all the states of a chain communicate with each other, the chain is called *irreducible*.\n",
"\n",
"The sticky reflecting random walk of the previous section is irreducible, because it is possible for the chain to get from every state to every other state."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Period ###\n",
"Working in discrete time has disadvantages. One of them is that states can be *periodic*. Let's start with the example of a random walk where the steps are based on tosses of a fair coin. Suppose the walk starts at state 0. Then it can return to 0 only at even times: the number of heads up to that point has to exactly equal the number of tails, and thus the number of tosses has to be even. We say that the state 0 *has period 2.* \n",
"\n",
"A state $i$ has *period* $d$ if, starting at $i$, the chain can come back to $i$ only at times that are multiples of $d$. That is, $d$ is the greatest common divisor of the set all $n$ such that $P_n(i, i) > 0$.\n",
"\n",
"In the random walk described above, all states have period 2. \n",
"\n",
"Period causes trouble with statements about long-run behavior. For example, if state $i$ has period 3, then the sequence $P_n(i, i)$ might look like \"0, 0, positive, 0, 0, positive, $\\ldots$\", so limit statements might become complicated. \n",
"\n",
"In this course we will study the long run behavior of chains in which all states are *aperiodic*, that is, they have period 1. In other words there is no cyclical pattern to when the chain can return to any state. \n",
"\n",
"How do you check if all states are aperiodic? If the chain is irreducible, it turns out that all the states must have the same period. The proof of this fact isn't terribly hard but we won't go through it. What it implies is that if a chain is irreducible, which is easy to check, all you have to do is figure out the period of one of its states. Then all the others must have the same period.\n",
"\n",
"Some states are easy to identify as aperiodic. If the one-step transition probability $P(i, i)$ is positive, then the state $i$ has to be aperiodic. Since the chain can stay at $i$ for arbitrary lengths of time, its \"returns\" are not cyclical."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example: Deconstructing a Chain ###\n",
"Consider the chain with transition matrix given by\n",
"\n",
"\n",
"| | **a** | **b** | **c** | **d** | **e** |\n",
"|-------|-------|-------|-------|-------|-------|\n",
"| **a** | 0 | 1 | 0 | 0 | 0 |\n",
"| **b** | 1 | 0 | 0 | 0 | 0 |\n",
"| **c** | 0 | 1/3 | 1/3 | 1/3 | 0 |\n",
"| **d** | 0 | 0 | 0 | 1/3 | 2/3 |\n",
"| **e** | 0 | 0 | 0 | 4/5 | 1/5 |\n",
"\n",
"- States $a$ and $b$ communicate with each other and with no other state, and thus are called a *communicating class*. The little matrix\n",
"\n",
"| | **a** | **b** |\n",
"|-------|-------|-------|\n",
"| **a** | 0 | 1 |\n",
"| **b** | 1 | 0 |\n",
"\n",
"is a transition matrix in its own right, albeit of a rather boring chain that goes deterministically back and forth between $a$ and $b$. Both $a$ and $b$ have period 2.\n",
"\n",
"- States $d$ and $e$ form their own communicating class and are aperiodic.\n",
"\n",
"| | **d** | **e** |\n",
"|-------|-------|-------|\n",
"| **d** | 1/3 | 2/3 |\n",
"| **e** | 4/5 | 1/5 |\n",
"\n",
"- State $c$ communicates with itself, but once it gets to either $b$ or $d$, it can't return."
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"In this course we will work only with **irreducible, aperiodic Markov chains on finite state spaces**. Much of what we say will be true for periodic chains as well, and for chains with countably infinite state spaces."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
}
},
"nbformat": 4,
"nbformat_minor": 1
}