# 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.

# Low-Rank Approximation Toolbox: Analysis of the Randomized SVD

In the previous post, we looked at the randomized SVD. In this post, we continue this discussion by looking at the analysis of the randomized SVD. Our approach is adapted from a new analysis of the randomized SVD by Joel A. Tropp and Robert J. Webber.

There are many types of analysis one can do for the randomized SVD. For instance, letting be a matrix and the rank- output of the randomized SVD, natural questions include:

• What is the expected error measured in some norm ? What about expected squared error ? How do these answers change with different norms?
• How large can the randomized SVD error get except for some small failure probability ?
• How close is the randomized SVD truncated to rank compared to the best rank- approximation to ?
• How close are the singular values and vectors of the randomized SVD approximation compared to those of ?

Implicitly and explicitly, the analysis of Tropp and Webber provides satisfactory answers to a number of these questions. In the interest of simplifying the presentation, we shall focus our presentation on just one of these questions, proving following result:

Here, is the Frobenius norm. We encourage the interested reader to check out Tropp and Webber’s paper to see the methodology we summarize here used to prove numerous facts about the randomized SVD and its extensions using subspace iteration and block Krylov iteration.

## Projection Formula

Let us recall the randomized SVD as we presented it in last post:

1. Collect information. Form where is an appropriately chosen random matrix.
2. Orthogonalize. Compute an orthonormal basis for the column space of by, e.g., thin QR factorization.
3. Project. Form , where denotes the conjugate transpose.

The randomized SVD is the approximation

It is easy to upgrade into a compact SVD form , as we did as steps 4 and 5 in the previous post.

For the analysis of the randomized SVD, it is helpful to notice that the approximation takes the form

Here, denotes the orthogonal projection onto the column space of the matrix . We call the projection formula for the randomized SVD.1This formula bares a good deal of similarity to the projection formula for the Nyström approximation. This is not a coincidence.

## Aside: Quadratic Unitarily Invariant Norms

To state our error bounds in the most general language, we can adopt the language of quadratic unitarily invariant norms. Recall that a square matrix is unitary if

You may recall from my post on Nyström approximation that a norm on matrices is unitarily invariant if

A unitarily invariant norm is said to be quadratic if there exists another unitarily invariant norm such that

(1)

Many examples of quadratic unitarily invariant norms are found among the Schatten -norms, defined as

Here, denote the decreasingly order singular values of . The Schatten -norm is the Frobenius norm of a matrix. The spectral norm (i.e., operator 2-norm) is the Schatten -norm, defined to be

The Schatten -norms are unitarily invariant norms for every . However, the Schatten -norms are quadratic unitarily invariant norms only for since

For the remainder of this post, we let and be a quadratic unitarily invariant norm pair satisfying (1).

## Error Decomposition

The starting point of our analysis is the following decomposition of the error of the randomized SVD:

(2)

Recall that we have defined to be an optimal rank- approximation to :

Thus, the error decomposition says that the excess error is bounded by

Using the projection formula, we can prove the error decomposition (2) directly:

The first line is the projection formula, the second is relation between and , and the third is the triangle inequality. For the fifth line, we use the fact that is an orthoprojector and thus has unit spectral norm together with the fact that

For the final inequality, we used commutation rule

## Bounding the Error

In this section, we shall continue to refine the error decomposition (2). Consider a thin SVD of , partitioned as

where

• and both have orthonormal columns,
• and are square diagonal matrices with nonnegative entries,
• and have columns, and
• is an matrix.

Under this notation, the best rank- approximation is . Define

We assume throughout that is full-rank (i.e., ).

Applying the error decomposition (2), we get

(3)

For the second line, we used the unitary invariance of . Observe that the column space of is a subset of the column space of so

(4)

Let’s work on simplifying the expression

First, observe that

Thus, the projector takes the form

Here, denotes the Moore–Penrose pseudoinverse, which reduces to the ordinary matrix inverse for a square nonsingular matrix. Thus,

(5)

Remarkably, this seemingly convoluted combination of matrices actually is a well-studied operation in matrix theory, the parallel sum. The parallel sum of positive semidefinite matrices and is defined as

(6)

We will have much more to say about the parallel sum soon. For now, we use this notation to rewrite (5) as

Plugging this back into (4) and then (3), we obtain the error bound

(7)

Simplifying this expression further will require more knowledge about parallel sums, which we shall discuss now.

## Aside: Parallel Sums

Let us put aside the randomized SVD for a moment and digress to the seemingly unrelated topic of electrical circuits. Suppose we have a battery of voltage and we connect the ends using a wire of resistance . The current is given by Ohm’s law

Similarly, if the wire is replaced by a different wire with resistance , the current is then

Now comes the interesting question. What if we connect the battery by both wires (resistances and ) simultaneously in parallel, so that current can flow through either wire? Since wires of resistances and still have voltage , Ohm’s law still applies and thus the total current is

The net effect of connecting resisting wires of resistances and is the same as a single resisting wire of resistance

(8)

We call the the operation the parallel sum of and because it describes how resistances combine when connected in parallel.

The parallel sum operation can be extended to all nonnegative numbers and by continuity:

Electrically, this definition states that one obtains a short circuit (resistance ) if either of the wires carries zero resistance.

Parallel sums of matrices were introduced by William N. Anderson, Jr. and Richard J. Duffin as a generalization of the parallel sum operation from electrical circuits. There are several equivalent definitions. The natural definition (8) applies for positive definite matrices

This definition can be extended to positive semidefinite matrices by continuity. It can be useful to have an explicit definition which applies even to positive semidefinite matrices. To do so, observe that the (scalar) parallel sum satisfies the identity

To extend to matrices, we capitalize the letters and use the Moore–Penrose pseudoinverse in place of the inverse:

This was the definition (6) of the parallel sum we gave above which we found naturally in our randomized SVD error bounds.

The parallel sum enjoys a number of beautiful properties, some of which we list here:

1. Symmetry. ,
2. Simplified formula. for positive definite matrices,
3. Bounds. and .
4. Monotone. is monotone in the Loewner order.
5. Concavity. The map is (jointly) concave (with respect to the Loewner order).
6. Conjugation. For any square , .
7. Trace. .2In fact, this property holds with the trace replaced by any positive linear map. That is, if is a linear map from square matrices to square matrices satisfying if , then .
8. Unitarily invariant norms. .

For completionists, we include a proof of the last property for reference.

Proof of Property 8
Let be the unitarily invariant norm dual to .3Dual with respect to the Frobenius inner product, that is. By duality, we have

The first line is duality, the second holds because , the third line is property 6, the fourth line is property 7, the fifth line is property 4, and the sixth line is duality.

## Nearing the Finish: Enter the Randomness

Equipped with knowledge about parallel sums, we are now prepared to return to bounding the error of the randomized SVD. Apply property 8 of the parallel sum to the randomized SVD bound (7) to obtain

This bound is totally deterministic: It holds for any choice of test matrix , random or otherwise. We can use this bound to analyze the randomized SVD in many different ways for different kinds of random (or non-random) matrices . Tropp and Webber provide a number of examples instantiating this general bound in different ways.

We shall present only the simplest error bound for randomized SVD. We make the following assumptions:

• The test matrix is standard Gaussian.4By which, we mean the entries of are independent and standard normal.
• The norm is the Frobenius norm .
• The randomized SVD rank is .

Under these assumptions and using the property , we obtain the following expression for the expected error of the randomized SVD

(9)

All that is left to is compute the expectation of . Remarkably, this can be done in closed form.

## Aside: Expectation of Gaussian–Inverse Gaussian Matrix Product

The final ingredient in our randomized SVD analysis is the following computation involving Gaussian random matrices. Let and be independent standard Gaussian random matrices with of size , . Then

For the probability lovers, we will now go on to prove this. For those who are less probabilistically inclined, this result can be treated as a black box.

Proof of Random Matrix Formula
To prove this, first consider a simpler case where does not appear:

Here, we used the fact that the entries are independent, mean-zero, and variance-one. Thus, applying this result conditionally on with , we get

(10)

To compute , we rewrite using the trace

The matrix is known as an inverse-Wishart matrix and is a well-studied random matrix model. In particular, its expectation is known to be . Thus, we obtain

Plugging into (10), we obtain the desired conclusion

This completes the proof.

## Wrapping it All Up

We’re now within striking distance. All that is left is to assemble the pieces we have been working with to obtain a final bound for the randomized SVD.

Recall we have chosen the random matrix to be standard Gaussian. By the rotational invariance of the Gaussian distribution, and are independent and standard Gaussian as well. Plugging the matrix expectation bound to (9) then completes the analysis

# Low-Rank Approximation Toolbox: Randomized SVD

The randomized SVD and its relatives are workhorse algorithms for low-rank approximation. In this post, I hope to provide a fairly brief introduction to this useful method. In the following post, we’ll look into its analysis.

The randomized SVD is dead-simple to state: To approximate an matrix by a rank- matrix, perform the following steps:

1. Collect information. Form where is an appropriately chosen random matrix.
2. Orthogonalize. Compute an orthonormal basis for the column space of by, e.g., thin QR factorization.
3. Project. Form . (Here, denotes the conjugate transpose of a complex matrix, which reduces to the ordinary transpose if the matrix is real.)

If all one cares about is a low-rank approximation to the matrix , one can stop the randomized SVD here, having obtained the approximation

As the name “randomized SVD” suggests, one can easily “upgrade” the approximation to a compact SVD format:

1. SVD. Compute a compact SVD of the matrix : where and and and is .
2. Clean up. Set .

We now have approximated by a rank- matrix in compact SVD form:

One can use the factors , , and of the approximation as estimates of the singular vectors and values of the matrix .

## What Can You Do with the Randomized SVD?

The randomized SVD has many uses. Pretty much anywhere you would ordinarily use an SVD is a candidate for the randomized SVD. Applications include model reduction, fast direct solvers, computational biology, uncertainty quantification, among numerous others.

To speak in broad generalities, there are two ways to use the randomized SVD:

• As an approximation. First, we could use as a compressed approximation to . Using the format , requires just numbers of storage, whereas requires a much larger numbers of storage. As I detailed at length in my blog post on low-rank matrices, many operations are cheap for the low-rank matrix . For instance, we can compute a matrix–vector product in roughly operations rather than the operations to compute . For these use cases, we don’t need the “SVD” part of the randomized SVD.
• As an approximate SVD. Second, we can actually use the , , and produced by the randomized SVD as approximations to the singular vectors and values of . In these applications, we should be careful. Just because is a good approximation to , it is not necessarily the case that , , and are close to the singular vectors and values of . To use the randomized SVD in this context, it is safest to use posterior diagnostics (such as the ones developed in this paper of mine) to ensure that the singular values/vectors of interest are computed to a high enough accuracy. A useful rule of thumb is the smallest two to five singular values and vectors computed by the randomized SVD are suspect and should be used in applications only with extreme caution. When the appropriate care is taken and for certain problems, the randomized SVD can provide accurate singular vectors far faster than direct methods.

## Accuracy of the Randomized SVD

How accurate is the approximation produced by the randomized SVD? No rank- approximation can be more accurate than the best rank- approximation to the matrix , furnished by an exact SVD of truncated to rank . Thus, we’re interested in how much larger is than .

### Frobenius Norm Error

A representative result describing the error of the randomized SVD is the following:

(1)

This result states that the average squared Frobenius-norm error of the randomized SVD is comparable with the best rank- approximation error for any . In particular, choosing , we see that the randomized SVD error is at most times the best rank- approximation

(2)

Choosing , we see that the randomized SVD has at most twice the error of the best rank- approximation

(3)

In effect, these results tell us that if we want an approximation that is nearly as good as the best rank- approximation, using an approximation rank of, say, or for the randomized SVD suffices. These results hold even for worst-case matrices. For nice matrices with steadily decaying singular values, the randomized SVD can perform even better than equations (2)–(3) would suggest.

### Spectral Norm Error

The spectral norm is often a better error metric for matrix computations than the Frobenius norm. Is the randomized SVD also comparable with the best rank- approximation when we use the spectral norm? In this setting, a representative error bound is

(4)

The spectral norm error of the randomized SVD depends on the Frobenius norm error of the best rank- approximation for .

Recall that the spectral and Frobenius norm can be defined in terms of the singular values of the matrix :

Rewriting (4) using these formulas, we get

Despite being interested in the largest singular value of the error matrix , this bound demonstrates that the randomized SVD incurs errors based on the entire tail of ‘s singular values . The randomized SVD is much worse than the best rank- approximation for a matrix with a long detail of slowly declining singular values.

## Improving the Approximation: Subspace Iteration and Block Krylov Iteration

We saw that the randomized SVD produces nearly optimal low-rank approximations when we measure using the Frobenius norm. When we measure using the spectral norm, we have a split decision: If the singular values decay rapidly, the randomized SVD is near-optimal; if the singular values decay more slowly, the randomized SVD can suffer from large errors.

Fortunately, there are two fixes to improve the randomized SVD in the presence of slowly decaying singular values:

• Subspace iteration: To improve the quality of the randomized SVD, we can combine it with the famous power method for eigenvalue computations. Instead of , we use the powered expression . Powering has the effect of amplifying the large singular values of and dimishing the influence of the tail.
• Block Krylov iteration: Subspace iteration is effective, but fairly wasteful. To compute we compute the block Krylov sequence

and throw away all but the last term. To make more economical use of resources, we can use the entire sequence as our information matrix :

Storing the entire block Krylov sequence is more memory-intensive but makes more efficient use of matrix products than subspace iteration.

Both subspace iteration and block Krylov iteration should be carefully implemented to produce accurate results.

Both subspace iteration and block Krylov iteration diminish the effect of a slowly decaying tail of singular values on the accuracy of the randomized SVD. The more slowly the tail decays, the larger one must take the number of iterations to obtain accurate results.

# The Hard Way to Prove Jensen’s Inequality

In this post, I want to discuss a very beautiful piece of mathematics I stumbled upon recently. As a warning, this post will be more mathematical than most, but I will still try and sand off the roughest mathematical edges. This post is adapted from a much more comprehensive post by Paata Ivanishvili. My goal is to distill the main idea to its essence, deferring the stochastic calculus until it cannot be avoided.

Jensen’s inequality is one of the most important results in probability.

Jensen’s inequality. Let be a (real) random variable and a convex function such that both and are defined. Then .

Here is the standard proof. A convex function has supporting lines. That is, at a point , there exists a slope such that for all . Invoke this result at and and take expectations to conclude that

In this post, I will outline a proof of Jensen’s inequality which is much longer and more complicated. Why do this? This more difficult proof illustrates an incredible powerful technique for proving inequalities, interpolation. The interpolation method can be used to prove a number of difficult and useful inequalities in probability theory and beyond. As an example, at the end of this post, we will see the Gaussian Jensen inequality, a striking generalization of Jensen’s inequality with many applications.

The idea of interpolation is as follows: Suppose I wish to prove for two numbers and . This may hard to do directly. With the interpolation method, I first construct a family of numbers , , such that and and show that is (weakly) increasing in . This is typically accomplished by showing the derivative is nonnegative:

To prove Jensen’s inequality by interpolation, we shall begin with a special case. As often in probability, the simplest case is that of a Gaussian random variable.

Jensen’s inequality for a Gaussian. Let be a standard Gaussian random variable (i.e., mean-zero and variance ) and let be a thrice-differentiable convex function satisfying a certain technical condition.1Specifically, we assume the regularity condition for some for any Gaussian random variable . Then

Note that the conclusion is exactly Jensen’s inequality, as we have assumed is mean-zero.

The difficulty with any proof by interpolation is to come up with the “right” . For us, the “right” answer will take the form

where starts with no randomness and is our standard Gaussian. To interpolate between these extremes, we increase the variance linearly from to . Thus, we define

Here, and throughout, denotes a Gaussian random variable with zero mean and variance .

Let’s compute the derivative of . To do this, let denote a small parameter which we will later send to zero. For us, the key fact will be that a can be realized as a sum of independent and random variables. Therefore, we write

We now evaluate by using Taylor’s formula

(1)

where lies between and . Now, take expectations,

The random variable has mean zero and variance so this gives

As we show below, the remainder term vanishes as . Thus, we can rearrange this expression to compute the derivative:

The second derivative of a convex function is nonnegative: for every . Therefore,

Jensen’s inequality is proven! In fact, we’ve proven the stronger version of Jensen’s inequality:

This strengthened version can yield improvements. For instance, if is -smooth

then we have

This inequality isn’t too hard to prove directly, but it does show that we’ve obtained something more than the simple proof of Jensen’s inequality.

Analyzing the Remainder Term
Let us quickly check that the remainder term vanishes as . Let’s do this. As an exercise, you can verify that our technical regularity condition implies . Thus, by Hölder’s inequality and setting to be ‘s Hölder conjugate (), we obtain

One can show that where is a function of alone. Therefore, as .

## What’s Really Going On Here?

In our proof, we use a family of random variables , defined for each . Rather than treating these quantities as independent, we can think of them as a collective, comprising a random function known as a Brownian motion.

The Brownian motion is a very natural way of interpolating between a constant and a Gaussian with mean .2The Ornstein–Uhlenbeck process is another natural way of interpolating between a random variable and a Gaussian.

There is an entire subject known as stochastic calculus which allows us to perform computations with Brownian motion and other random processes. The rules of stochastic calculus can seem bizarre at first. For a function of a real number , we often write

For a function of a Brownian motion, the analog is Itô’s formula

While this might seem odd at first, this formula may seem more sensible if we compare with (1) above. The idea, very roughly, is that for an increment of the Brownian motion over a time interval , is a random variable with mean , so we cannot drop the second term in the Taylor series, even up to first order in . Fully diving into the subtleties of stochastic calculus is far beyond the scope of this short post. Hopefully, the rest of this post, which outlines some extensions of our proof of Jensen’s inequality that require more stochastic calculus, will serve as an enticement to learn more about this beautiful subject.

## Proving Jensen by Interpolation

For the rest of this post, we will be less careful with mathematical technicalities. We can use the same idea that we used to prove Jensen’s inequality for a Gaussian random variable to prove Jensen’s inequality for any random variable :

Here is the idea of the proof.

First, realize that we can write any random variable as a function of a standard Gaussian random variable . Indeed, letting and denote the cumulative distribution functions of and , one can show that

has the same distribution as .

Now, as before, we can interpolate between and using a Brownian motion. As a first, idea, we might try

Unfortunately, this choice of does not work! Indeed, does not even equal to ! Instead, we must define

We define using the conditional expectation of the final value conditional on the Brownian motion at an earlier time . Using a bit of elbow grease and stochastic calculus, one can show that

This provides a proof of Jensen’s inequality in general by the method if interpolation.

## Gaussian Jensen Inequality

Now, we’ve come to the real treat, the Gaussian Jensen inequality. In the last section, we saw the sketch of a proof of Jensen’s inequality using interpolation. While it is cool that this proof is possible, we learned anything new since we can prove Jensen’s inequality in other ways. The Gaussian Jensen inequality provides an application of this technique which is hard to prove other ways. This section, in particular, is cribbing quite heavily from Paata Ivanishvili‘s excellent post on the topic.

Here’s the big question:

If are “somewhat dependent”, for which functions does the multivariate Jensen’s inequality

()

hold?

Considering extreme cases, if are entirely dependent, then we would only expect () to hold when is convex. But if are independent, then we can apply Jensen’s inequality to each coordinate one at a time to deduce

We would like a result which interpolates between extremes {fully dependent, fully convex} and {independent, separately convex}. The Gaussian Jensen inequality provides exactly this tool.

As in the previous section, we can generate arbitrary random variables as functions of Gaussian random variables . We will use the covariance matrix of the Gaussian random variables as our measure of the dependence of the random variables . With this preparation in place, we have the following result:

Gaussian Jensen inequality. The conclusion of Jensen’s inequality

(2)

holds for all test functions if and only if

Here, is the Hessian matrix at and denotes the entrywise product of matrices.

This is a beautiful result with striking consequences (see Ivanishvili‘s post). The proof is essentially the same as the proof as Jensen’s inequality by interpolation with a little additional bookkeeping.

Let us confirm this result respects our extreme cases. In the case where are equal (and variance one), is a matrix of all ones and for all . Thus, the Gaussian Jensen inequality states that (2) holds if and only if is positive semidefinite for every , which occurs precisely when is convex.

Next, suppose that are independent and variance one, then is the identity matrix and

A diagonal matrix is positive semidefinite if and only if its entries are nonnegative. Thus, (2) holds if and only if each of ‘s diagonal second derivatives are nonnegative : this is precisely the condition for to be separately convex in each argument.

There’s much more to be said about the Gaussian Jensen inequality, and I encourage you to read Ivanishvili‘s post to see the proof and applications. What I find so compelling about this result—so compelling that I felt the need to write this post—is how interpolation and stochastic calculus can be used to prove inequalities which don’t feel like stochastic calculus problems. The Gaussian Jensen inequality is a statement about functions of dependent Gaussian random variables; there’s nothing dynamic happening. Yet, to prove this result, we inject dynamics into the problem, viewing the two sides of our inequality as endpoints of a random process connecting them. This is a such a beautiful idea that I couldn’t help but share it.

# Big Ideas in Applied Math: Markov Chains

In this post, we’ll talk about Markov chains, a useful and general model of a random system evolving in time.

## PageRank

To see how Markov chains can be useful in practice, we begin our discussion with the famous PageRank problem￼. The goal is assign a numerical ranking to each website on the internet measuring how important it is. To do this, we form a mathematical model of an internet user randomly surfing the web. The importance of each website will be measured by the amount of times this user visits each page.

The PageRank model of an internet user is as follows: Start the user at an arbitrary initial website . At each step, the user makes one of two choices:

• With 85% probability, the user follows a random link on their current website.
• With 15% probability, the user gets bored and jumps to a random website selected from the entire internet.

As with any mathematical model, this is a riduculously oversimplified description of how a person would surf the web. However, like any good mathematical model, it is useful. Because of the way the model is designed, the user will spend more time on websites with many incoming links. Thus, websites with many incoming links will be rated as important, which seems like a sensible choice.

An example of the PageRank distribution for a small internet is shown below. As one would expect, the surfer spends a large part of their time on website B, which has many incoming links. Interestingly, the user spends almost as much of their time on website C, whose only links are to and from B. Under the PageRank model, a website is important if it is linked to by an important website, even if that is the only website linking to it.

## Markov Chains in General

Having seen one Markov chain, the PageRank internet surfer, let’s talk about Markov chains in general. A (time-homogeneous) Markov chain consists of two things: a set of states and probabilities for transitioning between states:

• Set of states. For this discussion, we limit ourselves to Markov chains which can only exist in finitely many different states. To simplify our discussion, label the possible states using numbers .
• Transition probabilities. The definining property of a (time-homogeneous) Markov chain is that, at any point in time , if the state is , the probability of moving to state is a fixed number . In particular, the probability of moving from to does not depend on the time or the past history of the chain before time ; only the value of the chain at time matters.

Denote the state of the Markov chain at times by . Note that the states are random quantities. We can write the Markov chain property using the language of conditional probability:

This equation states that the probability that the system is in state at time given the entire history of the system depends only on the value of the chain at time . This probability is the transition probability .

Let’s see how the PageRank internet surfer fits into this model:

• Set of states. Here, the set of states are the websites, which we label .
• Transition probabilities. Consider two websites and . If does not have a link to , then the only way of going from to is if the surfer randomly gets bored (probability 15%) and picks website to visit at random (probability ). Thus,

()

Suppose instead that does link to and has outgoing links. Then, in addition to the probability computed before, user has an 85% percent chance of following a link and a chance of picking as that link. Thus,

()

## Markov Chains and Linear Algebra

For a non-random process , we can understand the processes evolution by determining its state at every point in time . Since Markov chains are random processes, it is not enough to track the state of the process at every time . Rather, we must understand the probability distribution of the state at every point in time .

It is customary in Markov chain theory to represent a probability distribution on the states by a row vector .1To really emphasize that probability distributions are row vectors, we shall write them as transposes of column vectors. So is a column vector but represents the probability distribution as is a row vector. The th entry stores the probability that the system is in state . Naturally, as is a probability distribution, its entries must be nonnegative ( for every ) and add to one ().

Let denote the probability distributions of the states . It is natural to ask: How are the distributions related to each other? Let’s answer this question.

The probability that is in state is the th entry of :

To compute this probability, we break into cases based on the value of the process at time : either or or … or ; only one of these cases can be true at once. When we have an “or” of random events and these events are mutually exclusive (only can be true at once), then the probabilities add:

Now we use some conditional probability. The probability that and is the probability that times the probability that conditional on . That is,

Now, we can simplify using our definitions. The probability that is just and the probability of moving from to is . Thus, we conclude

Phrased in the language of linear algebra, we’ve shown

That is, if we view the transition probabilities as comprising an matrix , then the distribution at time is obtained by multiplying the distribution at time by transition matrix . In particular, if we iterate this result, we obtain that the distribution at time is given by

Thus, the distribution at time is the distribution at time multiplied by the th power of the transition matrix .

## Convergence to Stationarity

Let’s go back to our web surfer again. At time , we started our surfer at a particular website, say . As such, the probability distribution2To keep notation clean going forward, we will drop the transposes off of probability distributions, except when working with them linear algebraically. at time is concentrated just on website , with no other website having any probability at all. In the first few steps, most of the probability will remain in the vacinity of website , in the websites linked to by and the websites linked to by the websites linked to by and so on. However, as we run the chain long enough, the surfer will have time to widely across the web and the probability distribution will become less and less influenced by the chain’s starting location. This motivates the following definition:

Definition. A Markov chain satisfies the mixing property if the probability distributions converge to a single fixed probability distribution regardless of how the chain is initialized (i.e., independent of the starting distribution ).

The distribution for a mixing Markov chain is known as a stationary distribution because it does not change under the action of :

(St)

To see this, recall the recurrence

take the limit as , and observe that both and converge to .

One of the basic questions in the theory of Markov chains is finding conditions under which the mixing property (or suitable weaker versions of it) hold. To answer this question, we will need the following definition:

A Markov chain is primitive if, after running the chain for some number steps, the chain has positive probability of moving between any two states. That is,

The fundamental theorem of Markov chains is that primitive chains satisfy the mixing property.

Theorem (fundamental theorem of Markov chains). Every primitive Markov chain is mixing. In particular, there exists one and only probability distribution satisfying the stationary property (St) and the probability distributions converge to when initialized in any probability distribution . Every entry of is strictly positive.

Let’s see an example of the fundamental theorem with the PageRank surfer. After step, there is at least a chance of moving from any website to any other website . Thus, the chain is primitive. Consequently, there is a unique stationary distribution , and the surfer will converge to this stationary distribution regardless of which website they start at.

## Going Backwards in Time

Often, it is helpful to consider what would happen if we ran a Markov chain backwards in time. To see why this is an interesting idea, suppose you run website and you’re interested in where your traffic is coming from. One way of achieving this would be to initialize the Markov chain at and run the chain backwards in time. Rather than asking, “given I’m at now, where would a user go next?”, you ask “given that I’m at now, where do I expect to have come from?”

Let’s formalize this notion a little bit. Consider a primitive Markov chain with stationary distribution . We assume that we initialize this Markov chain in the stationary distribution. That is, we pick as our initial distribution for . The time-reversed Markov chain is defined as follows: The probability of moving from to in the time-reversed Markov chain is the probability that I was at state one step previously given that I’m at state now:

To get a nice closed form expression for the reversed transition probabilities , we can invoke Bayes’ theorem:

(Rev)

The time-reversed Markov chain can be a strange beast. For the reversed PageRank surfer, for instance, follows links “upstream” traveling from the linked site to the linking site. As such, our hypothetical website owner could get a good sense of where their traffic is coming from by initializing the reversed chain at their website and following the chain one step back.

## Reversible Markov Chains

We now have two different Markov chains: the original and its time-reversal. Call a Markov chain reversible if these processes are the same. That is, if the transition probabilities are the same:

Using our formula (Rev) for the reversed transition probability, the reversibility condition can be written more concisely as

This condition is referred to as detailed balance.3There is an abstruse—but useful—way of reformulating the detailed balance condition. Think of a vector as defining a function on the set , . Letting denote a random variable drawn from the stationary distribution , we can define a non-standard inner product on : . Then the Markov chain is reversible if and only if detailed balance holds if and only if is a self-adjoint operator on when equipped with the non-standard inner product . This more abstract characterization has useful consequences. For instance, by the spectral theorem, the transition matrix of a reversible Markov chain has real eigenvalues and supports a basis of orthonormal eigenvectors (in the inner product). In words, it states that a Markov chain is reversible if, when initialized in the stationary distribution , the flow of probability mass from to (that is, ) is equal to the flow of probability mass from to (that is, ).

Many interesting Markov chains are reversible. One class of examples are Markov chain models of physical and chemical processes. Since physical laws like classical and quantum mechanics are reversible under time, so too should we expect Markov chain models built from theories to be reversible.

Not every interesting Markov chain is reversible, however. Indeed, except in special cases, the PageRank Markov chain is not reversible. If links to but. does not link to , then the flow of mass from to will be higher than the flow from to .

Before moving on, we note one useful fact about reversible Markov chains. Suppose a reversible, primitive Markov chain satisfies the detailed balance condition with a probability distribution :

Then is the stationary distribution of this chain. To see why, we check the stationarity condition . Indeed, for every ,

The second equality is detailed balance and the third equality is just the condition that the sum of the transition probabilities from to each is one. Thus, and is a stationary distribution for . But a primitive chain has only one stationary distribution , so .

## Markov Chains as Algorithms

Markov chains are an amazingly flexible tool. One use of Markov chains is more scientific: Given a system in the real world, we can model it by a Markov chain. By simulating the chain or by studying its mathematical properties, we can hope to learn about the system we’ve modeled.

Another use of Markov chains is algorithmic. Rather than thinking of the Markov chain as modeling some real-world process, we instead design the Markov chain to serve a computationally useful end. The PageRank surfer is one example. We wanted to rank the importance of websites, so we designed a Markov chain to achieve this task.

One task we can use Markov chains to solve are sampling problems. Suppose we have a complicated probability distribution , and we want a random sample from —that is, a random quantity such that for every . One way to achieve this goal is to design a primitive Markov chain with stationary distribution . Then, we run the chain for a large number of steps and use as an approximate sample from .

To design a Markov chain with stationary distribution , it is sufficient to generate transition probabilities such that and satisfy the detailed balance condition. Then, we are guaranteed that is a stationary distribution for the chain. (We also should check the primitiveness condition, but this is often straightforward.)

Here is an effective way of building a Markov chain to sample from a distribution . Suppose that the chain is in state at time , . To choose the next state, we begin by sampling from a proposal distribution . The proposal distribution can be almost anything we like, as long as it satisfies three conditions:

• Probability distribution. For every , the transition probabilitie add to one: .
• Bidirectional. If , then .
• Primitive. The transition probabilities form a primitive Markov chain.

In order to sample from the correct distribution, we can’t just accept every proposal. Rather, given the proposal , we accept with probability

If we accept the proposal, the next state of our chain is . Otherwise, we stay where we are . This Markov chain is known as a Metropolis–Hastings sampler.

For clarity, we list the steps of the Metropolis–Hastings sampler explicitly:

1. Initialize the chain in any state and set .
2. Draw a proposal with from the proposal distribution, .
3. Compute the acceptance probability

4. With probability , set . Otherwise, set .
5. Set and go back to step 2.

To check that is a stationary distribution of the Metropolis–Hastings distribution, all we need to do is check detailed balance. Note that the probability of transitioning from to under the Metropolis–Hastings sampler is the proposal probability times the acceptance probability:

Detailed balance is confirmed by a short computation4Note that the detailed balance condition for is always satisfied for any Markov chain .

Thus the Metropolis–Hastings sampler has as stationary distribution.

## Determinatal Point Processes: Diverse Items from a Collection

The uses of Markov chains in science, engineering, math, computer science, and machine learning are vast. I wanted to wrap up with one application that I find particularly neat.

Suppose I run a bakery and I sell different baked goods. I want to pick out special items for a display window to lure customers into my store. As a first approach, I might pick my top- selling items for the window. But I realize that there’s a problem. All of my top sellers are muffins, so all of the items in my display window are muffins. My display window is doing a good job luring in muffin-lovers, but a bad job of enticing lovers of other baked goods. In addition to rating the popularity of each item, I should also promote diversity in the items I select for my shop window.

Here’s a creative solution to my display case problems using linear algebra. Suppose that, rather than just looking at a list of the sales of each item, I define a matrix for my baked goods. In the th entry of my matrix, I write the number of sales for baked good . I populate the off-diagonal entries of my matrix with a measure of similarity between items and .5There are many ways of defining such a similarity matrix. Here is one way. Let be the number ordered for each bakery item by a random customer. Set to be the correlation matrix of the random variables , with being the correlation between the random variables and . The matrix has all ones on its diagonal. The off-diagonal entries measure the amount that items and tend to be purchased together. Let be a diagonal matrix where is the total sales of item . Set . By scaling by the diagonal matrix , the diagonal entries of represent the popularity of each item, whereass the off-diagonal entries still represent correlations, now scaled by popularity. So if and are both muffins, will be large. But if is a muffin and is a cookie, then will be small. For mathematical reasons, we require to be symmetric and positive definite.

To populate my display case, I choose a random subset of items from my full menu of size according to the following strange probability distribution: The probability of picking items is proportional to the determinant of the submatrix . More specifically,

(-DPP)

Here, we let denote the submatrix of consisting of the entries appearing in rows and columns . Such a random subset is known as a -determinantal point process (-DPP). (See this survey for more about DPPs.)

To see why this makes any sense, let’s consider a simple example of items and a display case of size . Suppose I have three items: a pumpkin muffin, a chocolate chip muffin, and an oatmeal raisin cookies. Say the matrix looks like

We see that both muffins are equally popular and much more popular than the cookie . However, the two muffins are similar to each other and thus the corresponding submatrix has small determinant

By contrast, if the cookie is disimilar to each muffin and the determinant is higher

Thus, even though the muffins are more popular overall, choosing our display case from a -DPP, we have a chance of choosing a muffin and a cookie for our display case. It is for this reason that we can say that a -DPP preferentially selects for diverse items.

Is sampling from a -DPP the best way of picking items for my display case? How does it compare to other possible methods?6Another method I’m partial to for this task is randomly pivoted Cholesky sampling, which is computationally cheaper than -DPP sampling even with the Markov chain sampling approach to -DPP sampling that we will discuss shortly. These are interesting questions for another time. For now, let us focus our attention on a different question: How would you sample from a -DPP?

## Determinantal Point Process by Markov Chains

Sampling from a -DPP is a hard computational problem. Indeed, there are possible -element subspaces of a set of items. The number of possibilities gets large fast. If I have items and want to pick of them, there are already over 10 trillion possible combinations.

Markov chains offer one compelling way of sampling a -DPP. First, we need a proposal distribution. Let’s choose the simplest one we can think of:

Proposal for -DPP sampling. Suppose our current set of items is . To generate a proposal, choose a uniformly random element out of and a uniformly random element out of without . Propose obtained from by replacing with (i.e., ).

Now, we need to compute the Metropolis–Hastings acceptance probability

For and which differ only by the addition of one element and the removal of another, the proposal probabilities and are both equal to , . Using the formula for the probability of drawing from a -DPP, we compute that

Thus, the Metropolis–Hastings acceptance probability is just a ratio of determinants:

(Acc)

And we’re done. Let’s summarize our sampling algorithm:

1. Choose an initial set arbitrarily and set .
2. Draw uniformly at random from .
3. Draw uniformly at random from .
4. Set .
5. With probability defined in (Acc), accept and set . Otherwise, set .
6. Set and go to step 2.

This is a remarkably simple algorithm to sample from a complicated distribution. And its fairly efficient as well. Analysis by Anari, Oveis Gharan, and Rezaei shows that, when you pick a good enough initial set , this sampling algorithm produces approximate samples from a -DPP in roughly steps.7They actually use a slight variant of this algorithm where the acceptance probabilities (Acc) are reduced by a factor of two. Observe that this still has the correct stationary distribution because detailed balance continues to hold. The extra factor is introduced to ensure that the Markov chain is primitive. Remarkably, if is much smaller than , this Markov chain-based algorithm samples from a -DPP without even looking at all entries of the matrix !

Upshot. Markov chains are a simple and general model for a state evolving randomly in time. Under mild conditions, Markov chains converge to a stationary distribution: In the limit of a large number of steps, the state of the system become randomly distributed in a way independent of how it was initialized. We can use Markov chains as algorithms to approximately sample from challenging distributions.

# Note to Self: Norm of a Gaussian Random Vector

Let be a standard Gaussian vector—that is, a vector populated by independent standard normal random variables. What is the expected length of ? (Here, and throughout, denotes the Euclidean norm of a vector.) The length of is the square root of the sum of independent standard normal random variables

which is known as a random variable with degrees of freedom. (Not to be confused with a random variable!) Its mean value is given by the rather unpleasant formula

where is the gamma function. If you are familiar with the definition of the gamma function, the derivation of this formula is not too hard—it follows from a change of variables to -dimensional spherical coordinates.

This formula can be difficult to interpret and use. Fortunately, we have the rather nice bounds

(1)

This result appears, for example, page 11 of this paper. These bounds show that, for large , is quite close to . The authors of the paper remark that this inequality can be probed by induction. I had difficulty reproducing the inductive argument for myself. Fortunately, I found a different proof which I thought was very nice, so I thought I would share it here.

Our core tool will be Wendel’s inequality (see (7) in Wendel’s original paper): For and , we have

(2)

Let us first use Wendel’s inequality to prove (1). Indeed, invoke Wendel’s inequality with and and multiply by to obtain

which simplifies directly to (1).

Now, let’s prove Wendel’s inequality (2). The key property for us will be the strict log-convexity of the gamma function: For real numbers and ,

(3)

We take this property as established and use it to prove Wendel’s inequality. First, use the log-convexity property (3) with to obtain

Divide by and use the property that to conclude

(4)

This proves the upper bound in Wendel’s inequality (2). To prove the lower bound, invoke the upper bound (4) with in place of and in place of to obtain

Multiplying by , dividing by , and using again yields

finishing the proof of Wendel’s inequality.

Notes. The upper bound in (1) can be proven directly by Lyapunov’s inequality: , where we use the fact that is the sum of random variables with mean one. The weaker lower bound follows from a weaker version of Wendel’s inequality, Gautschi’s inequality.

After the initial publication of this post, Sam Buchanan mentioned another proof of the lower bound using the Gaussian Poincaré inequality. This inequality states that, for a function ,

To prove the lower bound, set which has gradient . Thus,

Rearrange to obtain .

# Stochastic Trace Estimation

I am delighted to share that me, Joel A. Tropp, and Robert J. Webber‘s paper XTrace: Making the Most of Every Sample in Stochastic Trace Estimation has recently been released as a preprint on arXiv. In it, we consider the implicit trace estimation problem:

Implicit trace estimation problem: Given access to a square matrix via the matrix–vector product operation , estimate its trace .

Algorithms for this task have many uses such as log-determinant computations in machine learning, partition function calculations in statistical physics, and generalized cross validation for smoothing splines. I described another application to counting triangles in a large network in a previous blog post.

Our paper presents new trace estimators XTrace and XNysTrace which are highly efficient, producing accurate trace approximations using a small budget of matrix–vector products. In addition, these algorithms are fast to run and are supported by theoretical results which explain their excellent performance. I really hope that you will check out the paper to learn more about these estimators!

For the rest of this post, I’m going to talk about the most basic stochastic trace estimation algorithm, the GirardHutchinson estimator. This seemingly simple algorithm exhibits a number of nuances and forms the backbone for more sophisticated trace estimates such as Hutch++, Nyström++, XTrace, and XNysTrace. Toward the end, this blog post will be fairly mathematical, but I hope that the beginning will be fairly accessible to all.

## Girard–Hutchinson Estimator: The Basics

The GirardHutchinson estimator for the trace of a square matrix is

(1)

Here, are random vectors, usually chosen to be statistically independent, and denotes the conjugate transpose of a vector or matrix. The Girard–Hutchinson estimator only depends on the matrix through the matrix–vector products .

### Unbiasedness

Provided the random vectors are isotropic

(2)

the Girard–Hutchinson estimator is unbiased:

(3)

Let us confirm this claim in some detail. First, we use linearity of expectation to evaluate

(4)

Therefore, to prove that , it is sufficient to prove that for each .

When working with traces, there are two tricks that solve 90% of derivations. The first trick is that, if we view a number as a matrix, then a number equals its trace, . The second trick is the cyclic property: For a matrix and a matrix , we have . The cyclic property should be handled with care when one works with a product of three or more matrices. For instance, we have

However,

One should think of the matrix product as beads on a closed loop of string. One can move the last bead to the front of the other two, , but not interchange two beads, .

With this trick in hand, let’s return to proving that for every . Apply our two tricks:

The expectation is a linear operation and the matrix is non-random, so we can bring the expectation into the trace as

Invoke the isotropy condition (2) and conclude:

Plugging this into (4) confirms the unbiasedness claim (3).

### Variance

Continue to assume that the ‘s are isotropic (3) and now assume that are independent. By independence, the variance can be written as

Assuming that are identically distributed , we then get

The variance decreases like , which is characteristic of Monte Carlo-type algorithms. Since is unbiased (i.e, (3)), this means that the mean square error decays like so the average error (more precisely root-mean-square error) decays like

This type of convergence is very slow. If I want to decrease the error by a factor of , I must do the work!

Variance-reduced trace estimators like Hutch++ and our new trace estimator XTrace improve the rate of convergence substantially. Even in the worst case, Hutch++ and XTrace reduce the variance at a rate and (root-mean-square) error at rates :

For matrices with rapidly decreasing singular values, the variance and error can decrease much faster than this.

## Variance Formulas

As the rate of convergence for the Girard–Hutchinson estimator is so slow, it is imperative to pick a distribution on test vectors that makes the variance of the single–sample estimate as low as possible. In this section, we will provide several explicit formulas for the variance of the Girard–Hutchinson estimator. Derivations of these formulas will appear at the end of this post. These variance formulas help illuminate the benefits and drawbacks of different test vector distributions.

To express the formulas, we will need some notation. For a complex number we use and to denote the real and imaginary parts. The variance of a random complex number is

The Frobenius norm of a matrix is

If is real symmetric or complex Hermitian with (real) eigenvalues , we have

(5)

denotes the ordinary transpose of and denotes the conjugate transpose of .

### Real-Valued Test Vectors

We first focus on real-valued test vectors . Since is real, we can use the ordinary transpose rather than the conjugate transpose . Since is a number, it is equal to its own transpose:

Therefore,

The Girard–Hutchinson trace estimator applied to is the same as the Girard–Hutchinson estimator applied to the symmetric part of , .

For the following results, assume is symmetric, .

1. Real Gaussian: are independent standard normal random vectors.

2. Uniform signs (Rademachers): are independent random vectors with uniform coordinates.

3. Real sphere: Assume are uniformly distributed on the real sphere of radius : .

These formulas continue to hold for nonsymmetric by replacing by its symmetric part on the right-hand sides of these variance formulas.

### Complex-Valued Test Vectors

We now move our focus to complex-valued test vectors . As a rule of thumb, one should typically expect that the variance for complex-valued test vectors applied to a real symmetric matrix is about half the natural real counterpart—e.g., for complex Gaussians, you get about half the variance than with real Gaussians.

A square complex matrix has a Cartesian decomposition

where

denote the Hermitian and skew-Hermitian parts of . Similar to how the imaginary part of a complex number is real, the skew-Hermitian part of a complex matrix is Hermitian (and is skew-Hermitian). Since and are both Hermitian, we have

Consequently, the variance of can be broken into Hermitian and skew-Hermitian parts:

For this reason, we will state the variance formulas only for Hermitian , with the formula for general following from the Cartesian decomposition.

For the following results, assume is Hermitian, .

1. Complex Gaussian: are independent standard complex random vectors, i.e., each has iid entries distributed as for standard normal random variables.

2. Uniform phases (Steinhauses): are independent random vectors whose entries are uniform on the complex unit circle .

3. Complex sphere: Assume are uniformly distributed on the complex sphere of radius : .

## Optimality Properties

Let us finally address the question of what the best choice of test vectors is for the Girard–Hutchinson estimator. We will state two results with different restrictions on .

Our first result, due to Hutchinson, is valid for real symmetric matrices with real test vectors.

Optimality (independent test vectors with independent coordinates). If the test vectors are isotropic (2), independent from each other, and have independent entries, then for any fixed real symmetric matrix , the minimum variance for is obtained when are populated with random signs .

The next optimality results will have real and complex versions. To present the results for -valued and an -valued test vectors on unified footing, let denote either or . We let a -Hermitian matrix be either a real symmetric matrix (if ) or a complex Hermitian matrix (if ). Let a -unitary matrix be either a real orthogonal matrix (if ) or a complex unitary matrix (if ).

The condition that the vectors have independent entries is often too restrictive in practice. It rules out, for instance, the case of uniform vectors on the sphere. If we relax this condition, we get a different optimal distribution:

Optimality (independent test vectors). Consider any set of -Hermitian matrices which is invariant under -unitary similary transformations:

Assume that the test vectors are independent and isotropic (2). The worst-case variance is minimized by choosing uniformly on the -sphere: .

More simply, if you wants your stochastic trace estimator to be effective for a class of inputs (closed under -unitary similarity transformations) rather than a single input matrix , then the best distribution are test vectors drawn uniformly from the sphere. Examples of classes of matrices include:

• Fixed eigenvalues. For fixed real eigenvalues , the set of all -Hermitian matrices with these eigenvalues.
• Density matrices. The class of all trace-one psd matrices.
• Frobenius norm ball. The class of all -Hermitian matrices of Frobenius norm at most 1.

## Derivation of Formulas

In this section, we provide derivations of the variance formulas. I have chosen to focus on derivations which are shorter but use more advanced techniques rather than derivations which are longer but use fewer tricks.

### Real Gaussians

First assume is real. Since is real symmetric, has an eigenvalue decomposition , where is orthogonal and is a diagonal matrix reporting ‘s eigenvalues. Since the real Gaussian distribution is invariant under orthogonal transformations, has the same distribution as . Therefore,

Here, we used that the variance of a squared standard normal random variable is two.

For non-real matrix, we can break the matrix into its entrywise real and imaginary parts . Thus,

### Uniform Signs

First, compute

For a vector of uniform random signs, we have for every , so the second sum vanishes. Note that we have assumed symmetric, so the sum over can be replaced by two times the sum over :

Note that are pairwise independent. As a simple exercise, one can verify that the identity

holds for any pairwise independent family of random variances and numbers . Ergo,

In the second-to-last line, we use the fact that is a uniform random sign, which has variance . The final line is a consequence of the symmetry of .

### Uniform on the Real Sphere

The simplest proof is I know is by the “camel principle”. Here’s the story (a lightly edited quotation from MathOverflow):

A father left 17 camels to his three sons and, according to the will, the eldest son was to be given a half of the camels, the middle son one-third, and the youngest son the one-ninth. The sons did not know what to do since 17 is not evenly divisible into either two, three, or nine parts, but a wise man helped the sons: he added his own camel, the oldest son took camels, the second son took camels, the third son camels and the wise man took his own camel and went away.

We are interested in a vector which is uniform on the sphere of radius . Performing averages on the sphere is hard, so we add a camel to the problem by “upgrading” to a spherically symmetric vector which has a random length. We want to pick a distribution for which the computation is easy. Fortunately, we already know such a distribution, the Gaussian distribution, for which we already calculated .

The Gaussian vector and the uniform vector on the sphere are related by

where is the squared length of the Gaussian vector . In particular, has the distribution of the sum of squared Gaussian random variables, which is known as a random variable with degrees of freedom.

Now, we take the camel back. Compute the variance of using the chain rule for variance:

Here, and denote the conditional variance and conditional expectation with respect to the random variable . The quick and dirty ways of working with these are to treat the random variable “like a constant” with respect to the conditional variance and expectation.

Plugging in the formula and treating “like a constant”, we obtain

As we mentioned, is a random variable with degrees of freedom and and are known quantities that can be looked up:

We know and . Plugging these all in, we get

Rearranging, we obtain

### Complex Gaussians

The trick is the same as for real Gaussians. By invariance of complex Gaussian random vectors under unitary transformations, we can reduce to the case where is a diagonal matrix populated with eigenvalues . Then

Here, we use the fact that is a random variable with two degrees of freedom, which has variance four.

### Random Phases

The trick is the same as for uniform signs. A short calculation (remembering that is Hermitian and thus ) reveals that

The random variables are pairwise independent so we have

Since is uniformly distributed on the complex unit circle, we can assume without loss of generality that . Thus, letting be uniform on the complex unit circle,

The real and imaginary parts of have the same distribution so

so . Thus

### Uniform on the Complex Sphere: Derivation 1 by Reduction to Real Case

There are at least three simple ways of deriving this result: the camel trick, reduction to the real case, and Haar integration. Each of these techniques illustrates a trick that is useful in its own right beyond the context of trace estimation. Since we have already seen an example of the camel trick for the real sphere, I will present the other two derivations.

Let us begin with the reduction to the real case. Let and denote the real and imaginary parts of a vector or matrix, taken entrywise. The key insight is that if is a uniform random vector on the complex sphere of radius , then

We’ve converted the complex vector into a real vector .

Now, we need to convert the complex matrix into a real matrix . To do this, recall that one way of representing complex numbers is by matrices:

Using this correspondence addition and multiplication of complex numbers can be carried by addition and multiplication of the corresponding matrices.

To convert complex matrices to real matrices, we use a matrix-version of the same representation:

One can check that addition and multiplication of complex matrices can be carried out by addition and multiplication of the corresponding “realified” matrices, i.e.,

holds for all complex matrices and .

We’ve now converted complex matrix and vector into real matrix and vector . Let’s compare to . A short calculation reveals

Since is a uniform random vector on the sphere of radius , is a uniform random vector on the sphere of radius . Thus, by the variance formula for the real sphere, we get

A short calculation verifies that and . Plugging this in, we obtain

### Uniform on the Complex Sphere: Derivation 2 by Haar Integration

The proof by reduction to the real case requires some cumbersome calculations and requires that we have already computed the variance in the real case by some other means. The method of Haar integration is more slick, but it requires some pretty high-power machinery. Haar integration may be a little bit overkill for this problem, but this technique is worth learning as it can handle some truly nasty expected value computations that appear, for example, in quantum information.

We seek to compute

The first trick will be to write this expession using a single matrix trace using the tensor (Kronecker) product . For those unfamiliar with the tensor product, the main properties we will be using are

(6)

We saw in the proof of unbiasedness that

Therefore, by (6),

Thus, to evaluate , it will be sufficient to evaluate . Forunately, there is a useful formula for these expectation provided by a field of mathematics known as representation theory (see Lemma 1 in this paper):

Here, is the orthogonal projection onto the space of symmetric two-tensors . Therefore, we have that

To evalute the trace on the right-hand side of this equation, there is another formula (see Lemma 6 in this paper):

Therefore, we conclude

## Proof of Optimality Properties

In this section, we provide proofs of the two optimality properties.

### Optimality: Independent Vectors with Independent Coordinates

Assume is real and symmetric and suppose that is isotropic (2) with independent coordinates. The isotropy condition

implies that , where is the Kronecker symbol. Using this fact, we compute the second moment:

Thus

The variance is minimized by choosing with as small as possible. Since , the smallest possible value for is , which is obtained by populating with random signs.

### Optimality: Independent Vectors

This result appears to have first been proven by Richard Kueng in unpublished work. We use an argument suggested to me by Robert J. Webber.

Assume is a class of -Hermitian matrices closed under -unitary similarity transformations and that is an isotropic random vector (2). Decompose the test vector as

First, we shall show that the variance is reduced by replacing with a vector drawn uniformly from the sphere

(7)

where

(8)

Note that such a can be generated as for a uniformly random -unitary matrix . Therefore, we have

Now apply Jensen’s inequality only over the randomness in to obtain

Finally, note that since is closed under -unitary similarity transformations, the supremum over for is the same as the supremum of , so we obtain

We have successfully proven (7). This argument is a specialized version of a far more general result which appears as Proposition 4.1 in this paper.

Next, we shall prove

(9)

where is still defined as in (8). Indeed, using the chain rule for variance, we obtain

Here, we have used that is uniform on the sphere and thus . By definition, is the length of divided by . Therefore,

Therefore, by Jensen’s inequality,

Thus

which proves (9).

# Low-Rank Approximation Toolbox: Nyström, Cholesky, and Schur

In the last post, we looked at the Nyström approximation to an positive semidefinite (psd) matrix . A special case was the column Nyström approximation, defined to be1We use Matlab index notation to indicate submatrices of .

(Nys)

where identifies a subset of columns of . Provided , this allowed us to approximate all entries of the matrix using only the entries in columns of , a huge savings of computational effort!

With the column Nyström approximation presented just as such, many questions remain:

• Why this formula?
• Where did it come from?
• How do we pick the columns ?
• What is the residual of the approximation?

In this post, we will answer all of these questions by drawing a connection between low-rank approximation by Nyström approximation and solving linear systems of equations by Gaussian elimination. The connection between these two seemingly unrelated areas of matrix computations will pay dividends, leading to effective algorithms to compute Nyström approximations by the (partial) Cholesky factorization of a positive (semi)definite matrix and an elegant description of the residual of the Nyström approximation as the Schur complement.

## Cholesky: Solving Linear Systems

Suppose we want solve the system of linear equations , where is a real invertible matrix and is a vector of length . The standard way of doing this in modern practice (at least for non-huge matrices ) is by means of Gaussian elimination/LU factorization. We factor the matrix as a product of a lower triangular matrix and an upper triangular matrix .2To make this accurate, we usually have to reorder the rows of the matrix as well. Thus, we actually compute a factorization where is a permutation matrix and and are triangular. The system is solved by first solving for and then for ; the triangularity of and make solving the associated systems of linear equations easy.

For real symmetric positive definite matrix , a simplification is possible. In this case, one can compute an LU factorization where the matrices and are transposes of each other, . This factorization is known as a Cholesky factorization of the matrix .

The Cholesky factorization can be easily generalized to allow the matrix to be complex-valued. For a complex-valued positive definite matrix , its Cholesky decomposition takes the form , where is again a lower triangular matrix. All that has changed is that the transpose has been replaced by the conjugate transpose . We shall work with the more general complex case going forward, though the reader is free to imagine all matrices as real and interpret the operation as ordinary transposition if they so choose.

## Schur: Computing the Cholesky Factorization

Here’s one way of computing the Cholesky factorization using recursion. Write the matrix in block form as

Our first step will be “block Cholesky factorize” the matrix , factoring as a product of matrices which are only block triangular. Then, we’ll “upgrade” this block factorization into a full Cholesky factorization.

The core idea of Gaussian elimination is to combine rows of a matrix to introduce zero entries. For our case, observe that multiplying the first block row of by and subtracting this from the second block row introduces a matrix of zeros into the bottom left block of . (The matrix is a principal submatrix of and is therefore guaranteed to be positive definite and thus invertible.3To directly see is positive definite, for instance, observe that since is positive definite, for every nonzero vector .) In matrix language,

Isolating on the left-hand side of this equation by multiplying by

yields the block triangular factorization

We’ve factored into block triangular pieces, but these pieces are not (conjugate) transposes of each other. Thus, to make this equation more symmetrical, we can further decompose

(1)

This is a block version of the Cholesky decomposition of the matrix taking the form , where is a block lower triangular matrix and is a block diagonal matrix.

We’ve met the second of our main characters, the Schur complement

(Sch)

This seemingly innocuous combination of matrices has a tendency to show up in surprising places when one works with matrices.4See my post on the Schur complement for more examples. It’s appearance in any one place is unremarkable, but the shear ubiquity of in matrix theory makes it deserving of its special name, the Schur complement. To us for now, the Schur complement is just the matrix appearing in the bottom right corner of our block Cholesky factorization.

The Schur complement enjoys the following property:5This property is a consequence of equation (1) together with the conjugation rule for positive (semi)definiteness, which I discussed in this previous post.

Positivity of the Schur complement: If is positive (semi)definite, then the Schur complement is positive (semi)definite.

As a consequence of this property, we conclude that both and are positive definite.

With the positive definiteness of the Schur complement in hand, we now return to our Cholesky factorization algorithm. Continue by recursively6As always with recursion, one needs to specify the base case. For us, the base case is just that Cholesky decomposition of a matrix is . computing Cholesky factorizations of the diagonal blocks

Inserting these into the block factorization (1) and simplifying gives a Cholesky factorization, as desired:

Voilà, we have obtained a Cholesky factorization of a positive definite matrix !

By unwinding the recursions (and always choosing the top left block to be of size ), our recursive Cholesky algorithm becomes the following iterative algorithm: Initialize to be the zero matrix. For , perform the following steps:

1. Update . Set the th column of :

2. Update . Update the bottom right portion of to be the Schur complement:

This iterative algorithm is how Cholesky factorization is typically presented in textbooks.

## Nyström: Using Cholesky Factorization for Low-Rank Approximation

Our motivating interest in studying the Cholesky factorization was the solution of linear systems of equations for a positive definite matrix . We can also use the Cholesky factorization for a very different task, low-rank approximation.

Let’s first look at things through the lense of the recursive form of the Cholesky factorization. The first step of the factorization was to form the block Cholesky factorization

Suppose that we choose the top left block to be of size , where is much smaller than . The most expensive part of the Cholesky factorization will be the recursive factorization of the Schur complement , which is a large matrix of size .

To reduce computational cost, we ask the provocative question: What if we simply didn’t factorize the Schur complement? Observe that we can write the block Cholesky factorization as a sum of two terms

(2)

We can use the first term of this sum as a rank- approximation to the matrix . The low-rank approximation, which we can write out more conveniently as

is the column Nyström approximation (Nys) to associated with the index set and is the final of our three titular characters. The residual of the Nyström approximation is the second term in (2), which is none other than the Schur complement (Sch), padded by rows and columns of zeros:

Observe that the approximation is obtained from the process of terminating a Cholesky factorization midway through algorithm execution, so we say that the Nyström approximation results from a partial Cholesky factorization of the matrix .

Summing things up:

If we perform a partial Cholesky factorization on a positive (semi)definite matrix, we obtain a low-rank approximation known as the column Nyström approximation. The residual of this approximation is the Schur complement, padded by rows and columns of zeros.

The idea of obtaining a low-rank approximation from a partial matrix factorization is very common in matrix computations. Indeed, the optimal low-rank approximation to a real symmetric matrix is obtained by truncating its eigenvalue decomposition and the optimal low-rank approximation to a general matrix is obtained by truncating its singular value decomposition. While the column Nyström approximation is not the optimal rank- approximation to (though it does satisfy a weaker notion of optimality, as discussed in this previous post), it has a killer feature not possessed by the optimal approximation:

The column Nyström approximation is formed from only columns from the matrix . A column Nyström approximation approximates an matrix by only reading a fraction of its entries!

Unfortunately there’s not a free lunch here. The column Nyström is only a good low-rank approximation if the Schur complement has small entries. In general, this need not be the case. Fortunately, we can improve our situation by means of pivoting.

Our iterative Cholesky algorithm first performs elimination using the entry in position followed by position and so on. There’s no need to insist on this exact ordering of elimination steps. Indeed, at each step of the Cholesky algorithm, we can choose whichever diagonal position that we want to perform elimination. The entry we choose to perform elimination with is called a pivot.

Obtaining good column Nyström approximations requires identifying the a good choice for the pivots to reduce the size of the entries of the Schur complement at each step of the algorithm. With general pivot selection, an iterative algorithm for computing a column Nyström approximation by partial Cholesky factorization proceeds as follows: Initialize an matrix to store the column Nyström approximation , in factored form. For , perform the following steps:

1. Select pivot. Choose a pivot .
2. Update the approximation. .
3. Update the residual. .

This procedure results in the Nyström approximation (Nys) with column set :

The pivoted Cholesky steps 1–3 requires updating the entire matrix at every step. With a little more cleverness, we can optimize this procedure to only update the entries of the matrix we need to form the approximation . See Algorithm 2 in this preprint of my coauthors and I for details.

How should we choose the pivots? Two simple strategies immediately suggest themselves:

• Uniformly random. At each step , select uniformly at random from among the un-selected pivot indices.
• Greedy.7The greedy pivoting selection is sometimes known as diagonal pivoting or complete pivoting in the numerical analysis literature. At each step , select according to the largest diagonal entry of the current residual :

The greedy strategy often (but not always) works well, and the uniformly random approach can work surprisingly well if the matrix is “incoherent”, with all rows and columns of the matrix possessing “similar importance”.

Despite often working fairly well, both the uniform and greedy schemes can fail significantly, producing very low-quality approximations. My research (joint with Yifan Chen, Joel A. Tropp, and Robert J. Webber) has investigated a third strategy striking a balance between these two approaches:

• Diagonally weighted random. At each step , select at random according to the probability weights based on the current diagonal of the matrix

Our paper provides theoretical analysis and empirical evidence showing that this diagonally-weighted random pivot selection (which we call randomly pivoted Cholesky aka RPCholesky) performs well at approximating all positive semidefinite matrices , even those for which uniform random and greedy pivot selection fail. The success of this approach can be seen in the following examples (from Figure 1 in the paper), which shows RPCholesky can produce much smaller errors than the greedy and uniform methods.

## Conclusions

In this post, we’ve seen that a column Nyström approximation can be obtained from a partial Cholesky decomposition. The residual of the approximation is the Schur complement. I hope you agree that this is a very nice connection between these three ideas. But beyond its mathematical beauty, why do we care about this connection? Here are my reasons for caring:

• Analysis. Cholesky factorization and the Schur complement are very well-studied in matrix theory. We can use known facts about Cholesky factorization and Schur complements to prove things about the Nyström approximation, as we did when we invoked the positivity of the Schur complement.
• Algorithms. Cholesky factorization-based algorithms like randomly pivoted Cholesky are effective in practice at producing high-quality column Nyström approximations.

On a broader level, our tale of Nyström, Cholesky, and Schur demonstrates that there are rich connections between low-rank approximation and (partial versions of) classical matrix factorizations like LU (with partial pivoting), Cholesky, QR, eigendecomposition, and SVD for to full-rank matrices. These connections can be vital to analyzing low-rank approximation algorithms and developing improvements.

# Low-Rank Approximation Toolbox: Nyström Approximation

Welcome to a new series for this blog, Low-Rank Approximation Toolbox. As I discussed in a previous post, many matrices we encounter in applications are well-approximated by a matrix with a small rank. Efficiently computing low-rank approximations has been a major area of research, with applications in everything from classical problems in computational physics and signal processing to trendy topics like data science. In this series, I want to explore some broadly useful algorithms and theoretical techniques in the field of low-rank approximation.

I want to begin this series by talking about one of the fundamental types of low-rank approximation, the Nyström approximation of a (real symmetric or complex Hermitian) positive semidefinite (psd) matrix . Given an arbitrary “test matrix” , the Nyström approximation is defined to be

(1)

This formula is sensible whenever is invertible; if is not invertible, then the inverse should be replaced by the Moore–Penrose pseudoinverse . For simplicity, I will assume that is invertible in this post, though everything we discuss will continue to work if this assumption is dropped. I use to denote the conjugate transpose of a matrix, which agrees with the ordinary transpose for real matrices. I will use the word self-adjoint to refer to a matrix which satisfies .

The Nyström approximation (1) answers the question

What is the “best” rank- approximation to the psd matrx provided only with the matrix–matrix product , where is a known matrix ()?

Indeed, if we let , we observe that the Nyström approximation can be written entirely using and :

This is central advantage of the Nyström approximation: to compute it, the only access to the matrix I need is the ability to multiply the matrices and . In particular, I only need a single pass over the entries of to compute the Nyström approximation. This allows the Nyström approximation to be used in settings when other low-rank approximations wouldn’t work, such as when is streamed to me as a sum of matrices that must be processed as they arrive and then discarded.

## Choosing the Test Matrix

Every choice of test matrix defines a rank- Nyström approximation1Actually, is only rank at most . For this post, we will use rank- to mean “rank at most “. by (1). Unfortunately, the Nyström approximation won’t be a good low-rank approximation for every choice of . For an example of what can go wrong, if we pick to have columns selected from the eigenvectors of with small eigenvalues, the approximation will be quite poor.

The very best choice of would be the eigenvectors associated with the largest eigenvalues. Unfortunately, computing the eigenvectors to high accuracy is computationally costly. Fortunately, we can get decent low-rank approximations out of much simpler ‘s:

1. Random: Perhaps surprisingly, we get a fairly low-rank approximation out of just choosing to be a random matrix, say, populated with statistically independent standard normal random entries. Intuitively, a random matrix is likely to have columns with meaningful overlap with the large-eigenvalue eigenvectors of (and indeed with any fixed orthonormal vectors). One can also pick more exotic kinds of random matrices, which can have computational benefits.
2. Random then improve: The more similar the test matrix is to the large-eigenvalue eigenvectors of , the better the low-rank approximation will be. Therefore, it makes sense to use the power method (usually called subspace iteration in this context) to improve a random initial test matrix to be closer to the eigenvectors of .2Even better than subspace iteration is block Krylov iteration. See section 11.6 of the following survey for details.
3. Column selection: If consists of columns of the identity matrix, then just consists of columns of : In MATLAB notation,

This is highly appealing as it allows us to approximate the matrix by only reading a small fraction of its entries (provided )! Producing a good low-rank approximation requires selecting the right column indices (usually under the constraint of reading a small number of entries from ). In my research with Yifan Chen, Joel A. Tropp, and Robert J. Webber, I’ve argued that the most well-rounded algorithm for this task is a randomly pivoted partial Cholesky decomposition.

## The Projection Formula

Now that we’ve discussed the choice of test matrix, we shall explore the quality of the Nyström approximation as measured by the size of the residual . As a first step, we shall show that the residual is psd. This means that is an underapproximation to .

The positive semidefiniteness of the residual follows from the following projection formula for the Nyström approximation:

Here, denotes the the orthogonal projection onto the column space of the matrix . To deduce the projection formula, we break down as in (1):

The fact that the paranthesized quantity is can be verified in a variety of ways, such as by QR factorization.3Let , where has orthonormal columns and is square and upper triangular. The orthogonal projection is . The parenthesized expression is .

With the projection formula in hand, we easily obtain the following expression for the residual:

To show that this residual is psd, we make use of the conjugation rule.

Conjugation rule: For a matrix and a self-adjoint matrix , if is psd then is psd. If is invertible, then the converse holds: if is psd, then is psd.

The matrix is an orthogonal projection and therefore psd. Thus, by the conjugation rule, the residual of the is Nyström approximation is psd:

## Optimality of the Nyström Approximation

There’s a question we’ve been putting off that can’t be deferred any longer:

Is the Nyström approximation actually a good low-rank approximation?

As we discussed earlier, the answer to this question depends on the test matrix . Different choices for give different approximation errors. See the following papers for Nyström approximation error bounds with different choices of . While the Nyström approximation can be better or worse depending on the choice of , what is true about Nyström approximation for every choice of is that:

The Nyström approximation is the best possible rank- approximation to given the information .

In precise terms, I mean the following:

Theorem: Out of all self-adjoint matrices spanned by the columns of with a psd residual , the Nyström approximation has the smallest error as measured by either the spectral or Frobenius norm (or indeed any unitarily invariant norm, see below).

Let’s break this statement down a bit. This result states that the Nyström approximation is the best approximation to under three conditions:

2. is spanned by the columns of .

I find these first two requirements to be natural. Since is self-adjoint, it makes sense to require our approximation to be as well. The stipulation that is spanned by the columns seems like a very natural requirement given we want to think of approximations which only use the information . Additionally, requirement 2 ensures that has rank at most , so we are really only considering low-rank approximations to .

The last requirement is less natural:

1. The residual is psd.

This is not an obvious requirement to impose on our approximation. Indeed, it was a nontrivial calculation using the projection formula to show that the Nyström approximation itself satisfies this requirement! Nevertheless, this third stipulation is required to make the theorem true. The Nyström approximation (1) is the best “underapproximation” to the matrix to in the span of .

## Intermezzo: Unitarily Invariant Norms and the Psd Order

To prove our theorem about the optimality of the Nyström approximation, we shall need two ideas from matrix theory: unitarily invariant norms and the psd order. We shall briefly describe each in turn.

A norm defined on the set of matrices is said to be unitarily invariant if the norm of a matrix does not change upon left- or right-multiplication by a unitary matrix:

Recall that a unitary matrix (called a real orthogonal matrix if is real-valued) is one that obeys . Unitary matrices preserve the Euclidean lengths of vectors, which makes the class of unitarily invariant norms highly natural. Important examples include the spectral, Frobenius, and nuclear matrix norms:

The unitarily invariant norm of a matrix depends entirely on its singular values . For instance, the spectral, Frobenius, and nuclear norms take the forms

In addition to being entirely determined by the singular values, unitarily invariant norms are non-decreasing functions of the singular values: If the th singular value of is larger than the th singular value of for , then for every unitarily invariant norm . For more on unitarily invariant norms, see this short and information-packed blog post from Nick Higham.

Our second ingredient is the psd order (also known as the Loewner order). A self-adjoint matrix is larger than a self-adjoint matrix according to the psd order, written , if the difference is psd. As a consequence, if and only if is psd, where here denotes the zero matrix of the same size as . Using the psd order, the positive semidefiniteness of the Nyström residual can be written as .

If and are both psd matrices and is larger than in the psd order, , it seems natural to expect that is larger than in norm. Indeed, this intuitive statement is true, at least when one restricts oneself to unitarily invariant norms.

Psd order and norms. If , then for every unitarily invariant norm .

This fact is a consequence of the following observations:

• If , then the eigenvalues of are larger than in the sense that the th largest eigenvalue of is larger than the th largest eigenvalue of .
• The singular values of a psd matrix are its eigenvalues.
• Unitarily invariant norms are non-decreasing functions of the singular values.

## Optimality of the Nyström Approximation: Proof

In this section, we’ll prove our theorem showing the Nyström approximation is the best low-rank approximation satisfying properties 1, 2, and 3. To this end, let be any matrix satisfying properties 1, 2, and 3. Because of properties 1 (self-adjointness) and 2 (spanned by columns of ), can be written in the form

where is a self-adjoint matrix. To make this more similar to the projection formula, we can factor on both sides to obtain

To make this more comparable to the projection formula, we can reparametrize by introducing a matrix with orthonormal columns with the same column space as . Under this parametrization, takes the form

The residual of this approximation is

(2)

We now make use of the of conjugation rule again. To simplify things, we make the assumption that is invertible. (As an exercise, see if you can adapt this argument to the case when this assumption doesn’t hold!) Since is psd (property 3), the conjugation rule tells us that

What does this observation tell us about ? We can apply the conjugation rule again to conclude

(Notice that since has orthonormal columns.)

We are now in a place to show that . Indeed,

The second line is the projection formula together with the observation that and the last line is the conjugation rule combined with the fact that is psd. Thus, having shown

we conclude