# Markov Musings 4: Should You Be Lazy?

This post is part of a series, Markov Musings, about the mathematical analysis of Markov chains. See here for the first post in the series.

In the previous post, we proved the following convergence results for a reversible Markov chain

Here, denotes the distribution of the chain at time , denotes the stationary distribution, denotes the divergence, and denote the decreasingly ordered eigenvalues of the Markov transition matrix . To bound the rate of convergence to stationarity, we therefore must upper bound and lower bound .

Having to prove separate bounds for two eigenvalues is inconvenient. In the next post, we will develop tools to bound . But what should we do about Fortunately, there is a trick.

## It Pays to be Lazy

Call a Markov chain lazy if, at every step, the chain has at least a 50% chance of staying put. That is, for every .

Any Markov chain can be made into a lazy chain. At every step of the chain, flip a coin. If the coin is heads, perform a step of the Markov chain as normal, drawing the next step randomly according to the transition matrix . If the coin comes up tails, do nothing and stay put.

Algebraically, the lazy chain described in the previous paragraph corresponds to replacing the original transition matrix with the lazy transition matrix , where denotes the identity matrix. It is easy to see that the stationary distribution for is also a stationary distribution for :

The eigenvalues of the lazy transition matrix are

In particular, since all of the original eigenvalues are , all of the eigenvalues of the lazy chain are . Thus, the smallest eigenvalue of is always and thus, for the lazy chain, the convergence is controlled only by :

Since it can be easier to establish bounds on the second eigenvalue than on both the second and last, it can be convenient—for theoretical purposes especially—to work with lazy chains, using the construction above to enforce laziness if necessary.

## Should You be Lazy?

We’ve seen one theoretical argument for why it pays to use lazy Markov chains. But should we use lazy Markov chains in practice? The answer ultimately depends on how we want to use the Markov chain.

Here are two very different ways we could use a Markov chain:

• One-shot sampling. Run the Markov chain once for a fixed number of steps , and use the result as an approximate sample from .

For this use case, it is important that the output is genuinely a sample from , and the possibility of large negative eigenvalues can significantly degrade the convergence. In the extreme case where is an eigenvalue, the chain will fail to converge to stationarity at all. For this application, the lazy approach may make sense.

• Averaging. Another way we can use a Markov chain is to compute the average of value of a function over a random variable drawn from the stationary distribution:

To do this, we approximate this expectation by the time average of the value of over the first values of the chain

As we shall see, this averaging process converges at an (asymptotically) slower rate for the lazy chain than the original chain. Therefore, for this application, we should typically just run the chain as-is, and not worry about making it lazy.

## The Case Against Laziness

To see why being lazy hurts us for the averaging problem, we will use the Markov chain central limit theorem. As with many random averaging processes, we expect that in the limit of a large number of steps , the Markov chain average

will become approximately normally distributed. This is the content of the Markov chain central limit theorem (CLT):

Informal theorem (Markov chain central limit theorem). Let denote the states of a Markov chain initialized in the stationary distribution . For a large number of steps, is approximately normally distributed with mean and variance where

(1)

The Markov chain CLT shows that the variance of the Markov chain average depends not only on the variance of in the stationary distribution, but also the covariance between and later values . The faster the covariance decreases, the smaller will be and thus the smaller the error for the Markov chain average.

More formally, the Markov chain CLT is given by the following result:

Theorem (Markov chain central limit theorem). As ,

converges in distribution to a normal random variable with mean zero and variance , as defined in (1).

To compare the lazy and non-lazy chains, let’s compute the variance parameter in the Markov chain CLT in terms of the eigenvalues of the chain. For the remainder of this post, let be any function.

### Step 1: Spectral Decomposition

Recall that, by the spectral theorem, the transition matrix has eigenvectors that are orthonormal in the -inner product

As in the previous post, we think of vectors such as as defining a function . Thus, we can expand the function using the eigenvectors

(2)

The first eigenvector is the vector of all ones (or, equivalently, the function that outputs for every output).

### Step 2: Applying the Transition Matrix to a Function

The transition matrix is defined so that if the Markov chain has probability distribution at time , then the chain has distribution at time . In other words, multiplying by on the right advances a distribution forward one step in time. This leads us to ask, what is the interpretation of multiplying a function by on the left. That is, is there an interpretation to the matrix–vector product ?

Indeed, there is such an interpretation: The th coordinate of is the expectation of conditional on the chain starting at :

Similarly,

(3)

There’s a straightforward proof of this fact. Let denote a probability distribution which places 100% of the probability mass on the single site . The th entry of is

We know that is the state of the Markov chain after steps when initialized in the initial distribution . Thus,

This proves the formula (3).

### Step 3: Computing the Covariance

With the help of the formula for and the spectral decomposition of , we are ready to compute the covariances appearing in (1).Let . Then

(4)

Let’s first compute and . Since is the vector/function of all ones, we have

For the last equality, we use the spectral decomposition (2) along with the orthonormality of the eigenvectors .

Since we assume the chain is initialized in the stationary distribution , it remains in stationarity at time , , so we have .

Now, let’s compute . Use the law of total expectation to write

Now, invoke (3) and the definition of the -inner product to write

Finally, using the spectral decomposition, we obtain

Combining this formula with our earlier observation that and plugging into (4), we obtain

(5)

For the second equality, we use that the largest eigenvalue is , so entirely drops out of the covariance.

### Step 4: Wrapping it Up

With the formula (5) for the covariance in hand, we are ready to evaluate the variance parameter in the Markov chain CLT. First, note that the variance is

Therefore, combining this formula for the variance and the formula (5) for the covariance, we obtain

Now, apply the formula for the sum of an infinite geometric series to obtain

(6)

### Conclusion: Laziness is (Asymptotically) Bad for Averaging

Before we get to the conclusions, let’s summarize where we are. We are seeking to use Markov chain average

as an approximation to the stationary mean . The Markov chain central limit theorem shows that, for a large number of steps , the error is approximately normally distributioned with mean zero and variance . So to obtain accurate estimates, we want to be as small as possible.

After some work, we were able to derive a formula (6) for in terms of the eigenvalues of the transition matrix . The formula for for the lazy chain is identical, except with each eigenvalue replaced by . Thus, we have

From these formulas, it is clear that the lazy Markov chain has a larger parameter and is thus less accurate than the non-lazy Markov chain, no matter what the eigenvalues are.

To compare the non-lazy and lazy chains in another way, consider the plot below. The blue solid line shows the amplification factor of an eigenvalue , which represents amount by which the squared coefficient is scaled by in . In the red-dashed line, we see the corresponding amplification factor for the corresponding eigenvalue of the lazy chain. We see that at every value, the lazy chain has a higher amplification factor than the original chain.

Remember that our original motivation for using the lazy chain was to remove the possibility of slow convergence of the chain to stationarity because of negative eigenvalues. But for the averaging application, negative eigenvalues are great. The process of Markov chain averaging shrinks the influence of negative eigenvalues on , whereas positive eigenvalues are amplified. For the averaging application, negative eigenvalues for the chain are a feature, not a bug.

## Moral of the Story

Much of Markov chain theory, particularly in theoretical parts of computer science, mathematics, and machine learning, is centered around proving convergence to stationarity. Negative eigenvalues are a genuine obstruction to convergence to stationarity, and using the lazy chain in practice may be a sensible idea if one truly needs a sample from the stationary distribution in a given application.

But one-shot sampling is not the only or even the most common uses for Markov chains in computational practice. For other applications, such as averaging, the negative eigenvalues are actually a help. Using the lazy chain in practice for these problems would be a poor idea.

To me, the broader lesson in this story is that, as applied mathematicians, it can be inadvisable to become too fixated on one particular mathematical benchmark for designing and analyzing algorithms. Proving rapid convergence to stationarity with respect to the total variation distance is one nice way to analyze Markov chains. But it isn’t the only way, and chains not possessing this property because of large negative eigenvalues may actually be better in practice for some problems. Ultimately, applied mathematics should, at least in part, be guided by applications, and paying attention to how algorithms are used in practice should inform how we build and evaluate new ones.

# Markov Musings 3: Spectral Theory

This post is part of a series, Markov Musings, about the mathematical analysis of Markov chains. See here for the first post in the series.

In the previous two posts, we proved the fundamental theorem of Markov chains using couplings and discussed the use of couplings to bound the mixing time, the time required for the chain to mix to near-stationarity.

In this post, we will continue this discussion by discussing spectral methods for understanding the convergence of Markov chains.

## Mathematical Setting

In this post, we will study a reversible Markov chain on with transition probability matrix and stationary distribution . Our goal will be to use the eigenvalues and eigenvectors of the matrix to understand the properties of the Markov chain.

Throughout our discussion, it will be helpful to treat vectors and functions as being one and the same, and we will use both and to denote the th entry of the vector (aka the evaluation of the function at ). By adopting this perspective, a vector is not merely a list of numbers, but instead labels each state with a numeric value.

Given a function/vector , we let denote the expected value of where is drawn from :

The variance is defined similarly:

As a final piece of notation, we let denote a probability distribution which assigns 100% probability to outcome .

## Spectral Theory

The eigenvalues and eigenvectors of general square matrices are ill-behaved creatures. Indeed, a general matrix with real entries can have complex-valued eigenvalues and fail to possess a full suite of linearly independent eigenvectors. The situation is dramatically better for symmetric matrices which obey the spectral theorem:

Theorem (spectral theorem for real symmetric matrices). An real symmetric matrix (i.e., one satisfying ) has real eigenvalues and orthonormal eigenvectors .

Unfortunately for us, the transition matrix for a reversible Markov chain is not always symmetric. But despite this, there’s a surprise: always has real eigenvalues. This leads us to ask:

Why does are the eigenvalues of the transition matrix real?

To answer this question, we will need to develop and a more general version of the spectral theorem and use our standing assumption that the Markov chain is reversible.

### The Transpose

In our quest to develop a general version of the spectral theorem, we look more deeply into the hypothesis of the theorem, namely that is equal to its transpose . Let’s first ask: What does the transpose mean?

Recall that is equipped with the standard inner product, sometimes called the Euclidean or dot product. We denote this product by and it is defined as

We can think of the standard inner product as defining the amount of the vector that points in the direction of .

The transpose of a matrix is closely related to the standard inner product. Specifically, is the (unique) matrix satisfying the adjoint property:

So the amount of in the direction of is the same as the amount of in the direction of .

### The Adjoint and the General Spectral Theorem

Since the transpose is intimately related to the standard inner product on , it is natural to wonder if non-standard inner products on give rise to non-standard versions of the transpose. This idea proves to be true.

Definition (adjoint). Let be any inner product on and let be an matrix. The adjoint of with respect to the inner product is the (unique) matrix such that

A matrix is self-adjoint if it equals its own adjoint, .

The spectral theorem naturally extends to the more abstract setting of adjoints with respect to non-standard inner products:

Theorem (general spectral theorem). Let be an matrix which is set-adjoint with respect to an inner product . Then has real eigenvalues and eigenvectors which are orthonormal:

### Reversibility and Self-Adjointness

The general spectral theorem offers us a path to understand our observation from above that the eigenvalues of are always real. Namely, we ask:

Is there an inner product under which is self-adjoint?

Fortunately, the answer is yes. Define the -inner product

This inner product is very natural. If and are mean-zero (), it reports the covariance of and where is drawn from .

Let us compute the adjoint of the transition matrix in the -inner product :

Recall that we have assumed our Markov chain is reversible. Thus, the detailed balance condition

implies that

Thus, we conclude that is self-adjoint.

We cannot emphasize enough that the reversibility assumption is crucial to ensure that is self-adjoint. In fact,

Theorem (reversibility and self-adjointness). The transition matrix of a general Markov chain with stationary distribution is self-adjoint in the -inner product if and only if the chain is reversible.

### Spectral Theorem for Markov Chains

Since is self-adjoint in the -inner product, the general spectral theorem implies the following

Corollary (spectral theorem for reversible Markov chain). The reversible Markov transition matrix has real eigenvalues associated with eigenvectors which are orthonormal in the -inner product:

Since is a reversible Markov transition matrix—not just any self-adjoint matrix—the eigenvalues of satisfy additional properties:

• Bounded. All of the eigenvalues of lie between and .1Here’s an argument. The vectors span all of , where denotes a vector with in position and elsewhere. Then, by the fundamental theorem of Markov chains, converges to for every . In particular, for any vector , . Thus, since for every vector , all of the eigenvalues must be in magnitude.
• Eigenvalue 1. is an eigenvalue of with eigenvector , where is a vector of all one’s.

For a primitive chain, we can also have the property:

• Contractive. For a primitive chain, all eigenvalues other than have magnitude .2This follows for every , so must be the unique left eigenvector with eigenvalue of modulus .

## Distance Between Probability Distributions Redux

In the previous post, we used the total variation distance to compare probability distributions:

Definition (total variation distance). The total variation distance between probability distributions and is

The total variation distance is an way of comparing two probability distributions since it can be computed by adding the absolute difference between the probabilities and of each outcome. Spectral theory plays more nicely with an “” way of comparing probability distributions, which we develop now.

### Densities

Given two probability densities and , the density of with respect to is the function3Note that we typically associate probability distributions and with row vectors, whereas the density is a function which we identify with column vectors. For those interested and familiar with measure theory, here is a good reason why this makes sense. In the continuum setting, probability distributions and are measures whereas the density remains a function, known as the Radon–Nikodym derivative . This provides a general way of figuring out which objects for finite state space Markov chains are row vectors and which are column vectors: Measures are row vectors whereas functions are column vectors. given by

The density satisfies the property that

(1)

To see why we call a density, it may be helpful to appeal to continuous probability for a moment. If is a random variable with distribution , the probability density function of (with respect to the uniform distribution ) is a function such that

The formula for the continuous case is exactly the same as the finite case (1) with sums replaced with integrals .

### The Chi-Squared Divergence

We are now ready to introduce our “” way of comparing probability distributions.

Definition (-divergence). The -divergence of with respect to is the variance of the density function:

To see the last equality is a valid formula for , note that

(2)

### Relations Between Distance Measures

The divergence always gives an upper bound on the total variation distance. Indeed, first note that we can express the total variation distance as

Thus, using Lyapunov’s inequality, we conclude

(3)

## Markov Chain Convergence by Eigenvalues

Now, we prove a quantitative version of the fundamental theorem of Markov chains (for reversible processes) using spectral theory and eigenvalues:4Note that we used the fundamental theorem of Markov chains in above footnotes to prove the “bounded” and “contractive” properties, so, at present, this purported proof of the fundamental theorem would be circular. Fortunately, we can establish these two claims independently of the fundamental theorem, say, by appealing to the Perron–Frobenius theorem. Thus, this argument does give a genuine non-circular proof of the fundamental theorem.

Theorem (Markov chain convergence by eigenvalues). Let denote the distributions of the Markov chain at times . Then

This raises a natural question: How large can the initial divergence between and be? This is answered by the next result.

Proposition (Initial distance to stationarity). For any ,

(4)

For any initial distribution , we have

(5)

The condition (4) is a direct computation

For (5), observe that is a convex function of the initial distribution . Therefore, its maximal value over the convex set of all probability distribution is maximized at an extreme point for some . Consequently, (5) follows directly from (4).

Using the previous two results and equation (3), we immediately obtain the following:

Corollary (Mixing time). When initialized from a distribution , the chain mixes to -total variation distance to stationarity

after

(6)

Indeed,

Equating the left-hand side with and rearranging gives (6).

### Proof of Markov Chain Convergence Theorem

We conclude with a proof of the Markov chain convergence result.

### Recurrence for Densities

Our first task is to derive a recurrence for the densities . To do this, we use the recurrence for the probability distribution:

Thus,

We now invoke the detailed balance , which implies

The product is an ordinary matrix–vector product. Thus, we have shown

(7)

### Spectral Decomposition

Now that we have a recurrence for the densities , we can understand how the densities change in time. Expand the initial density in eigenvectors of :

As we verified above in (1), we have . Thus, we conclude . Since the are eigenvectors of with eigenvalues , the recurrence (7) implies

### Conclusion

Finally, we compute

The theorem is proven.

# Markov Musings 2: Couplings

This post is part of a series, Markov Musings, about the mathematical analysis of Markov chains. See here for the first post in the series.

In the last post, we saw a proof of the fundamental theorem of Markov chains using the method of couplings. In this post, we will use couplings to provide quantitative bounds on the rate of Markov chain convergence.

## Mixing Time

Let us begin where the last post ended by recalling some facts about the mixing time of a Markov chain. Consider a Markov chain with stationary distribution . Recall that the mixing time is

Here, denotes the distribution of the state of the chain at time and is the total variation distance. For more on the total variation distance, see the previous post.

At the end of last post, we saw the following theorem, showing that the mixing time controls the rate of Markov chain convergence.

Theorem (mixing time as convergence rate). For any starting distribution ,

Consequently, if , then .

This result motivates us to develop techniques to bound the mixing time .

## Couplings and Convergence

In the previous post, we made essential use of couplings of probability distributions. In this post, we will extend this notion by using couplings of entire Markov chains.

Definition (coupling of Markov chains). A coupling of Markov chains with transition matrix are two processes and such that (A) each process is individually a Markov chain with transition matrix : In particular,

and (B) if , then .

A coupling of Markov chains thus consists of a pair of Markov chains which become glued together should they ever touch.

There are several ways we can use couplings to bound the mixing time of Markov chains. Here is one way. Let and be a coupling of Markov chains for which is initialized in some initial distribution and is initialized in the stationary distribution . Let be the time at which and meet:

The following theorem shows that the tails of the random variable control the convergence of the Markov chain to stationarity.

Theorem (convergence from couplings). Then .

This result is an immediate application of the coupling lemma from last post. Using this bound, we can bound the mixing time

Corollary (mixing time from couplings). .

The maximum is taken over all initial distributions .

Indeed, by the above theorem and Markov’s inequality,1For more on concentration inequalities such as Markov’s inequality, see my post on the subject.

Take a maximum over initial distribution and set . Then the left-hand side is at most , so

Rearranging gives the corollary.

## Example: Bit Strings

There are a number of examples2See, for instance, section 5.3 of Markov Chains and Mixing Times. to prove bounds on mixing times using the method of couplings, but we will focus on a simple but illustrative example: a lazy random walk on the set of bit strings.

A bit string is a sequence of 0’s and 1’s. Bit strings are used to store and represent information on digital computers. For instance, the character “a” is stored as “1100001” using the ASCII encoding.

### The Chain

Our example is a Markov chain whose states consist of all bit strings of length . For each step of the chain,

• With 50% probability, we do nothing and leave the state unchanged.
• With 50% probability, we choose a (uniform) random position from to and flip the bit in that position, changing 0 to 1 or 1 to 0.

One can think of this Markov chain as modeling a random process in which a bit string is corrupted by errors which flip a single bit. The stationary distribution for this chain is the uniform distribution on all bit strings (i.e., each bit string of length has the same probability ). Therefore, one can also think of this Markov chain as a very inefficient way of generating a string of random bits.3Another way of thinking about this Markov chain is as a random walk on the vertices of an -dimensional hypercube graph. With 50% probability, we stay put, and with 50% probability, we move along a random edge. Because we have a 50% probability of doing nothing, we call this process a lazy random walk.

### Designing the Coupling

Let us use the method of couplings to determine how fast this chain mixes. First, observe that there’s an alternative way of stating the transition rule for this Markov chain:

• Pick a (uniform) random position from to and set the bit in that position to with 50% probability and with 50% probability.

Indeed, under this rule, half of the time we leave the state unchanged because we set the bit in the selected position to the value it already had. For the other half of the time, we flip the selected bit.

Now, we construct a coupling. Initialize in an arbitrary distribution and in the stationary distribution (uniform over all bit strings). The key to construct a coupling will be to use the same randomness to update the state of both the “” chain and the “” chain. For this chain, there’s a natural way to do this.

At time , pick a (uniform) random position and a (uniform) random bit . Set by changing the th bit of to , and set by changing the th bit of to .

We couple the two chains by setting the same position to the same bit .

### Bounding the Mixing Time

To bound the mixing time, we need to understand when these two chains meet. Observe that if we pick position to set at some point, the two Markov chains have the same bit in position at every time later in the chain. Consequently,

If all of the positions have been chosen by time , then .

The two chains might meet before all of the positions have been chosen, but they are guaranteed to meet after.

Set to be the time at which all positions have been selected at least once. Then our observation is equivalent to saying that the meeting time is smaller than ,

Thus, to bound the mixing time, it is sufficient to compute the expected value of .

### Collecting Coupons

Computing the expected value of is actually an example of a very famous problem in probability theory known as the coupon collector problem. The classic version goes like this:

A cereal company is running a promotion where each box of cereal contains a coupon, which is equally likely to be any of one of different colors. A coupon of each color can be traded in for a toy. What is the expected number of boxes we need to open in order to qualify for the toy?

The coupon collector is exactly the same as our problem, with the different colors of coupons playing the same role as the different positions in our bit strings. Going forward, let’s use the language of coupons and boxes to describe this problem, as its more colorful.

When tackling a hard question like computing , it can be helpful to break into easier pieces. Let’s start with the simplest possible question: How many picks do we need to collect the first coupon? Just one. We always get a coupon in our first box.

With that question answered, let’s ask the next-simplest question: How many picks do we need to collect the second coupon, differently colored than the first? There are colors and of them are different from the first. So the probability of picking a new coupon in the second box is . In fact,

Until we succeed at picking the second unique coupon, every box has an independent chance of containing such a coupon.

The number of boxes needed is therefore a geometric random variable with success probability , and its mean is . On average, we need picks to collect the second coupon.

The reasoning is the same for the third coupon. There are coupons we haven’t collected and total, so the probability of picking the third coupon in each box is . Thus, the number of picks is a geometric random variable with success probability with mean .

In general, we need an expected picks to pick the th coupon. Adding up the expected number of picks for each , we obtain that the total number of picks required is to collect all the coupons is

More concisely, if we let denote the th harmonic number

then . Since the th harmonic number is at most , we have

### Conclusion

Putting all of these ingredients together, we obtain

The mixing time is (at most) proportional to .

More on Bit Strings and Collecting Coupons
Using more sophisticated techniques, it can be shown that the random variable satisfies

for every and , from which it follows that

Using a more sophisticated analysis—also based on couplings—we can improve this result to

for some constant . The constant in this inequality cannot be improved. See section 5.3.1 of Markov Chains and Mixing Times.

# Markov Musings 1: The Fundamental Theorem

For this summer, I’ve decided to open up another little mini-series on this blog called Markov Musings about the mathematical analysis of Markov chains, jumping off from my previous post on the subject. My main goal in writing this is to learn the material for myself, and I hope that what I produce is useful to others. My main resources are:

1. The book Markov Chains and Mixing Times by Levin, Peres, and Wilmer;
2. Lecture notes and videos by theoretical computer scientists Sinclair, Oveis Gharan, O’Donnell, and Schulman; and
3. These notes by Rob Webber, for a complementary perspective from a scientific computing point of view.

Be warned, these posts will be more mathematical in nature than most of the material on my blog.

In my previous post on Markov chains, we discussed the fundamental theorem of Markov chains. Here is a slightly stronger version:

Theorem (fundamental Theorem of Markov chains). A primitive Markov chain on a finite state space has a stationary distribution . When initialized from any starting distribution , the distributions of the chain at times converge at an exponential rate to .

My goal in this post will be to provide a proof of this fact using the method of couplings, adapted from the notes of Sinclair and Oveis Gharan. I like this proof because it feels very probabilistic (as opposed to more linear algebraic proofs of the fundamental theorem).

Here, and throughout, we say a matrix or vector is if all of its entries are strictly positive. Recall that a Markov chain with transition matrix is primitive if there exists for which . For this post, all Markov chains will have state space .

## Total Variation Distance

In order to quantify the rate of Markov chain convergence, we need a way of quantifying the closeness of two probability distributions. This motivates the following definition:

Definition (total variation distance). The total variation distance between probability distributions and on is the maximum difference between the probability of an event under and under :

The total variation distance is always between and . It is zero only when and are the same distribution. It is one only when and have disjoint supports—that is, there is no for which .

The total variation distance is a very strict way of comparing two probability distributions. Sinclair’s notes provide a vivid example. Suppose that denotes the uniform distribution on all possible ways of shuffling a deck of cards, and denotes the uniform distribution on all ways of shuffling cards with the ace of spades at the top. Then the total variation distance between and is . Thus, despite these distributions seeming quite similar to us, the total variation distance between and is almost as far apart as possible. There are a number of alternative ways of measuring the closeness of probability distributions, some of which are less severe.

## Couplings

Given a probability distribution , it can be helpful to work with random variables drawn from . Say a random variable is drawn from the distribution , written , if

To understand the total variation distance more, we shall need the following definition:

Definition (coupling). Given probability distributions on , a coupling is a distribution on such that if a pair of random variables is drawn from , then and . Denote the set of all couplings of and as .

More succinctly, a coupling of and is a joint distribution with marginals and .

Couplings are related to total variation distance by the following lemma:1A proof is provided in Lemma 4.2 of Oveis Gharan’s notes. The coupling lemma holds in the full generality of probability measures on general spaces, and can be viewed as a special case of the Monge–Kantorovich duality principle of optimal transport. See Theorem 4.13 and Example 4.14 in van Handel’s notes for details.

Lemma (coupling lemma). Let and be distributions on . Then

Here, represents the probability for variables drawn from joint distribution .

To see a simple example, suppose . Then the coupling lemma tells us that there is a coupling of and itself such that . Indeed, such a coupling can be obtained by drawing and setting . This defines a joint distribution under which with 100% probability.

To unpack the coupling lemma a little more, it really contains two statements:

• For any coupling between and and ,

• There exists a coupling between and such that when , then

We will need both of these statements in our proof of the fundamental theorem.

## Proof of the Fundamental Theorem

With these ingredients in place, we are now ready to prove the fundamental theorem of Markov chains. First, we will assume there exists a stationary distribution . We will provide a proof of this fact at the end of this post.

Suppose we initialize the chain in distribution , and let denote the distributions of the chain at times . Our goal will be to establish that as at an exponential rate.

### Distance to Stationarity is Non-Increasing

First, let us establish the more modest claim that is non-increasing

(1)

We shall do this by means of the coupling lemma.

Consider two versions of the chain and , one initialized in and the other initialized with . We now apply the coupling lemma to the states and of the chains at time . By the coupling lemma, there exists a coupling of and such that

Now construct a coupling of and according to the following rules:

• If , then draw according to the transition matrix and set .
• If , then run the two chains independently to generate and .

By the way we’ve designed the coupling,

Thus, by the coupling lemma,

We have established that the distance to stationarity is non-increasing.

This proof already contains the essence of the argument as to why Markov chains mix. We run two versions of the Markov chain, one initialized in an arbitrary distribution and the other initialized in the stationary distribution . While the states of the two chains are different, we run the chains independently. When the chains meet, we continue moving the chains together in synchrony. After running for long enough, the two chains are likely to meet, implying the chain has mixed.

### The All-to-All Case

As another stepping stone to the complete proof, let us prove the fundamental theorem in the special case where there is a strictly positive probability of moving between any two states, i.e., assuming .

Consider the two chains and coupled as in the previous section. We compute the probability more carefully. Write it as

(2)

To compute , break into cases for all possible values for to take

We now are in a place to lower bound this probability. Let be the minimum probability of moving between any two states

The probability of moving from, to is at least . We conclude the lower bound

Substituting back in (2), we obtain

By the coupling lemma, we conclude

By iteration, we conclude

The chain converges to stationarity at an exponential rate, as claimed.

### The General Case

We’ve now proved the fundamental theorem in the special case when . Fortunately, together with our earlier observation that distance to stationarity is non-increasing, we can upgrade this proof into a proof for the general case.

We have assumed the Markov chain is primitive, so there exists a time for which . Construct an auxilliary Markov chain such that one step of the auxilliary chain consists of running steps of the original chain:

By the all-to-all case, we know that converges to stationarity at an exponential rate. Thus, since the distribution of is , we have

where . Thus, since distance to stationarity is non-increasing, we have

Thus, for any starting distribution , the distribution of the chain at time converges to stationarity at an exponential rate as , proving the fundamental theorem.

## Mixing Time

We’ve proven a quantiative version of the fundamental theorem of Markov chains, showing that the total variation distance to stationarity decreases exponentially as a function of time. For algorithmic applications of Markov chains, we also care about the rate of convergence, as it dictates how long we need to run the chain. To this end, we define the mixing time:

Definition (mixing time). The mixing time of a Markov chain is the number of steps required for the distance to stationarity to be at most when started from a worst-case distribution:

The mixing time controls the rate of convergence for a Markov chain:

Theorem (mixing time as a convergence rate). For any starting distribution,

In particular, for to be within total variation distance of , we only need to run the chain for steps:

Corollary (time to mix to -stationarity). If , then .

These results can be proven using very similar techniques to the proof of the fundamental theorem from above. See Sinclair’s notes for more details.

Bonus: Existence of a Stationary Measure
To complete our probabilistic proof of the Markov chain convergence theorem, we must establish the existance of a stationary measure. We do this now.

Fix any state . Imagine starting the chain at and running it until it reaches again. Let be the expected number of times the chain hits in such a process, and set . Because the chain is primitive, all of the ‘s are well-defined, positive, and finite. Our claim will be that

is a stationary distribution for the chain. To prove this, it is sufficient to show that

(3)

Let us prove this. Let denote the values of the chain and denote the time at which the chain returns to . By linearity of expectation, the expected number of hits is the sum over all times of the probability that the chain is at at time before hitting . That is,

Break this sum into two pieces

The first term is just the transition probability . For the second term, break into cases depending on the value of the chain at time :

Combining these two terms, we get

Relabel the outer sum to go from to and exchange the order of summation to obtain

Recognize the term in the parentheses as . Thus, since , we have

which is exactly the claim (3) we wanted to show.