Singular Value Decomposition

Similar documents
Singular Value Decomposition

UNIT 6: The singular value decomposition.

(a) If A is a 3 by 4 matrix, what does this tell us about its nullspace? Solution: dim N(A) 1, since rank(a) 3. Ax =

Dimensionality Reduction: PCA. Nicholas Ruozzi University of Texas at Dallas

COMP 558 lecture 18 Nov. 15, 2010

Singular Value Decomposition

Deep Learning Book Notes Chapter 2: Linear Algebra

IV. Matrix Approximation using Least-Squares

Applied Mathematics 205. Unit II: Numerical Linear Algebra. Lecturer: Dr. David Knezevic

EE731 Lecture Notes: Matrix Computations for Signal Processing

Maths for Signals and Systems Linear Algebra in Engineering

Singular Value Decompsition

14 Singular Value Decomposition

MATH36001 Generalized Inverses and the SVD 2015

Numerical Methods I Singular Value Decomposition

Bindel, Fall 2009 Matrix Computations (CS 6210) Week 8: Friday, Oct 17

Chapter 3 Transformations

Linear Algebra for Machine Learning. Sargur N. Srihari

Principal Component Analysis

Linear Algebra, part 3 QR and SVD

Glossary of Linear Algebra Terms. Prepared by Vince Zaccone For Campus Learning Assistance Services at UCSB

The Singular Value Decomposition (SVD) and Principal Component Analysis (PCA)

Chapter 7: Symmetric Matrices and Quadratic Forms

Designing Information Devices and Systems II

Linear Algebra, part 3. Going back to least squares. Mathematical Models, Analysis and Simulation = 0. a T 1 e. a T n e. Anna-Karin Tornberg

MATRICES ARE SIMILAR TO TRIANGULAR MATRICES

COMP6237 Data Mining Covariance, EVD, PCA & SVD. Jonathon Hare

Linear Algebra - Part II

GI07/COMPM012: Mathematical Programming and Research Methods (Part 2) 2. Least Squares and Principal Components Analysis. Massimiliano Pontil

The Singular Value Decomposition

Singular Value Decomposition

Singular Value Decomposition

Large Scale Data Analysis Using Deep Learning

Notes on Eigenvalues, Singular Values and QR

The Singular Value Decomposition

be a Householder matrix. Then prove the followings H = I 2 uut Hu = (I 2 uu u T u )u = u 2 uut u

2. Review of Linear Algebra

Linear Algebra Review. Fei-Fei Li

Data Mining Lecture 4: Covariance, EVD, PCA & SVD

Lecture 8: Linear Algebra Background

Stat 159/259: Linear Algebra Notes

7. Symmetric Matrices and Quadratic Forms

Linear Systems. Carlo Tomasi. June 12, r = rank(a) b range(a) n r solutions

Principal Component Analysis

Linear Algebra Review. Fei-Fei Li

7 Principal Component Analysis

Proposition 42. Let M be an m n matrix. Then (32) N (M M)=N (M) (33) R(MM )=R(M)

Notes on singular value decomposition for Math 54. Recall that if A is a symmetric n n matrix, then A has real eigenvalues A = P DP 1 A = P DP T.

Computational Methods. Eigenvalues and Singular Values

The Singular Value Decomposition and Least Squares Problems

1 Linearity and Linear Systems

Principal Component Analysis

Exercise Sheet 1.

Eigenvalues and diagonalization

Math 102, Winter Final Exam Review. Chapter 1. Matrices and Gaussian Elimination

Review problems for MA 54, Fall 2004.

Properties of Matrices and Operations on Matrices

AM 205: lecture 8. Last time: Cholesky factorization, QR factorization Today: how to compute the QR factorization, the Singular Value Decomposition

Matrices and Vectors. Definition of Matrix. An MxN matrix A is a two-dimensional array of numbers A =

Linear Systems. Carlo Tomasi

Linear Algebra Primer

Knowledge Discovery and Data Mining 1 (VO) ( )

Conceptual Questions for Review

The QR Decomposition

CSE 554 Lecture 7: Alignment

Recall the convention that, for us, all vectors are column vectors.

Lecture 3: Review of Linear Algebra

CS 143 Linear Algebra Review

Linear Algebra: Matrix Eigenvalue Problems

Lecture 3: Review of Linear Algebra

Linear Algebra Review. Vectors

18.06SC Final Exam Solutions

Linear Algebra. Session 12

The SVD-Fundamental Theorem of Linear Algebra

B553 Lecture 5: Matrix Algebra Review

. = V c = V [x]v (5.1) c 1. c k

ECE 275A Homework #3 Solutions

Mathematical foundations - linear algebra

Machine Learning. B. Unsupervised Learning B.2 Dimensionality Reduction. Lars Schmidt-Thieme, Nicolas Schilling

The Singular Value Decomposition

LEC 2: Principal Component Analysis (PCA) A First Dimensionality Reduction Approach

THE SINGULAR VALUE DECOMPOSITION MARKUS GRASMAIR

DS-GA 1002 Lecture notes 0 Fall Linear Algebra. These notes provide a review of basic concepts in linear algebra.

The Gram Schmidt Process

The Gram Schmidt Process

Lecture notes on Quantum Computing. Chapter 1 Mathematical Background

Singular Value Decomposition (SVD)

Lecture notes: Applied linear algebra Part 1. Version 2

The study of linear algebra involves several types of mathematical objects:

1 Principal component analysis and dimensional reduction

Machine Learning. Principal Components Analysis. Le Song. CSE6740/CS7641/ISYE6740, Fall 2012

Linear Algebra. Shan-Hung Wu. Department of Computer Science, National Tsing Hua University, Taiwan. Large-Scale ML, Fall 2016

Linear Algebra- Final Exam Review

Lecture: Face Recognition and Feature Reduction

Singular Value Decomposition. 1 Singular Value Decomposition and the Four Fundamental Subspaces

Linear Least Squares. Using SVD Decomposition.

8. Diagonalization.

MATH 304 Linear Algebra Lecture 20: The Gram-Schmidt process (continued). Eigenvalues and eigenvectors.

Linear Algebra & Geometry why is linear algebra useful in computer vision?

Lecture 2: Linear Algebra Review

Transcription:

Chapter 6 Singular Value Decomposition In Chapter 5, we derived a number of algorithms for computing the eigenvalues and eigenvectors of matrices A R n n. Having developed this machinery, we complete our initial discussion of numerical linear algebra by deriving and making use of one final matrix factorization that exists for any matrix A R m n : the singular value decomposition (SVD). 6.1 Deriving the SVD For A R m n, we can think of the function x A x as a map taking points in R n to points in R m. From this perspective, we might ask what happens to the geometry of R n in the process, and in particular the effect A has on lengths of and angles between vectors. Applying our usual starting point for eigenvalue problems, we can ask the effect that A has on the lengths of vectors by examining critical points of the ratio R( x) = A x x over various values of x. Scaling x does not matter, since R(α x) = A α x α x = α α A x x = A x x = R( x). Thus, we can restrict our search to x with x = 1. Furthermore, since R( x) 0, we can instead consider [R( x)] 2 = A x 2 = x A A x. As we have shown in previous chapters, however, critical points of x A A x subect to x = 1 are exactly the eigenvectors x i satisfying A A x i = λ i x i ; notice λ i 0 and x i x = 0 when i = since A A is symmetric and positive semidefinite. Based on our use of the function R, the { x i } basis is a reasonable one for studying the geometric effects of A. Returning to this original goal, define y i A x i. We can make an additional observation about y i revealing even stronger eigenvalue structure: λ i y i = λ i A x i by definition of y i = A(λ i x i ) = A(A A x i ) since x i is an eigenvector of A A = (AA )(A x i ) by associativity = (AA ) y i 1

Thus, we have two cases: 1. When λ i = 0, then y i = 0. In this case, x i is an eigenvector of A A and y i = A x i is a corresponding eigenvector of AA with y i = A x i = A x i 2 = x i A A x i = λi x i. 2. When λ i = 0, y i = 0. An identical proof shows that if y is an eigenvector of AA, then x A y is either zero or an eigenvector of A A with the same eigenvalue. Take k to be the number of strictly positive eigenvalues λ i > 0 discussed above. By our construction above, we can take x 1,..., x k R n to be eigenvectors of A A and corresponding eigenvectors y 1,..., y k R m of AA such that A A x i = λ i x i AA y i = λ i y i for eigenvalues λ i > 0; here we normalize such that x i = y i = 1 for all i. Following traditional notation, we can define matrices V R n k and Ū R m k whose columns are x i s and y i s, resp. We can examine the effect of these new basis matrices on A. Take e i to be the i-th standard basis vector. Then, Ū A V e i = Ū A x i by definition of V = 1 λ i Ū A(λ i x i ) since we assumed λ i > 0 = 1 λ i Ū A(A A x i ) since x i is an eigenvector of A A = 1 λ i Ū (AA )A x i by associativity = 1 λi Ū (AA ) y i since we rescaled so that y i = 1 = λ i Ū y i since AA y i = λ i y i = λ i e i Take Σ = diag( λ 1,..., λ k ). Then, the derivation above shows that Ū A V = Σ. Complete the columns of Ū and V to U R m m and V R n n by adding orthonormal vectors x i and y i with A A x i = 0 and AA y i = 0, resp. In this case it is easy to show U AV e i = 0 and/or e i U AV = 0. Thus, if we take Σ i { λi i = and i k 0 otherwise then we can extend our previous relationship to show U AV = Σ, or equivalently A = UΣV. 2

This factorization is exactly the singular value decomposition (SVD) of A. The columns of U span the column space of A and are called its left singular vectors; the columns of V span its row space and are the right singular vectors. The diagonal elements σ i of Σ are the singular values of A; usually they are sorted such that σ 1 σ 2 0. Both U and V are orthogonal matrices. The SVD provides a complete geometric characterization of the action of A. Since U and V are orthogonal, they can be thought of as rotation matrices; as a diagonal matrix, Σ simply scales individual coordinates. Thus, all matrices A R m n are a composition of a rotation, a scale, and a second rotation. 6.1.1 Computing the SVD Recall that the columns of V simply are the eigenvectors of A A, so they can be computed using techniques discussed in the previous chapter. Since A = UΣV, we know AV = UΣ. Thus, the columns of U corresponding to nonzero singular values in Σ simply are normalized columns of AV; the remaining columns satisfy AA u i = 0, which can be solved using LU factorization. This strategy is by no means the most efficient or stable approach to computing the SVD, but it works reasonably well for many applications. We will omit more specialized approaches to finding the SVD but note that that many are simple extensions of power iteration and other strategies we already have covered that operate without forming A A or AA explicitly. 6.2 Applications of the SVD We devote the remainder of this chapter introducing many applications of the SVD. The SVD appears countless times in both the theory and practice of numerical linear linear algebra, and its importance hardly can be exaggerated. 6.2.1 Solving Linear Systems and the Pseudoinverse In the special case where A R n n is square and invertible, it is important to note that the SVD can be used to solve the linear problem A x = b. In particular, we have UΣV x = b, or x = VΣ 1 U b. In this case Σ is a square diagonal matrix, so Σ 1 simply is the matrix whose diagonal entries are 1/σ i. Computing the SVD is far more expensive than most of the linear solution techniques we introduced in Chapter 2, so this initial observation mostly is of theoretical interest. More generally, suppose we wish to find a least-squares solution to A x b, where A R m n is not necessarily square. From our discussion of the normal equations, we know that x must satisfy A A x = A b. Thus far, we mostly have disregarded the case when A is short or underdetermined, that is, when A has more columns than rows. In this case the solution to the normal equations is nonunique. To cover all three cases, we can solve an optimization problem of the following form: minimize x 2 such that A A x = A b 3

In words, this optimization asks that x satisfy the normal equations with the least possible norm. Now, let s write A = UΣV. Then, A A = (UΣV ) (UΣV ) = VΣ U UΣV since (AB) = B A = VΣ ΣV since U is orthogonal Thus, asking that A A x = A b is the same as asking VΣ ΣV x = VΣU b Or equivalently, Σ y = d if we take d U b and y V x. Notice that y = x since U is orthogonal, so our optimization becomes: minimize y 2 such that Σ y = d Since Σ is diagonal, however, the condition Σ y = d simply states σi y i = d i ; so, whenever σ i = 0 we must have y i = d i/σ i. When σ i = 0, there is no constraint on y i, so since we are minimizing y 2 we might as well take y i = 0. In other words, the solution to this optimization is y = Σ + d, where Σ + R n m has the following form: { Σ + 1/σi i =, σ i i = 0, and i k 0 otherwise This form in turn yields x = V y = VΣ + d = VΣ + U b. With this motivation, we make the following definition: Definition 6.1 (Pseudoinverse). The pseudoinverse of A = UΣV R m n is A + VΣ + U R n m. Our derivation above shows that the pseudoinverse of A enoys the following properties: When A is square and invertible, A + = A 1. When A is overdetermined, A + b gives the least-squares solution to A x b. When A is underdetermined, A + b gives the least-squares solution to A x b with minimal (Euclidean) norm. In this way, we finally are able to unify the underdetermined, fully-determined, and overdetermined cases of A x b. 6.2.2 Decomposition into Outer Products and Low-Rank Approximations If we expand out the product A = UΣV, it is easy to show that this relationship implies: A = l σ i u i v i, i=1 4

where l min{m, n}, and u i and v i are the i-th columns of U and V, resp. Our sum only goes to min{m, n} since we know that the remaining columns of U or V will be zeroed out by Σ. This expression shows that any matrix can be decomposed as the sum of outer products of vectors: Definition 6.2 (Outer product). The outer product of u R m and v R n is the matrix u v u v R m n. Suppose we wish to write the product A x. Then, instead we could write: ( l A x = σ i u i v i i=1 ) x l = σ i u i ( v i x) i=1 l = σ i ( v i x) u i since x y = x y i=1 So, applying A to x is the same as linearly combining the u i vectors with weights σ i ( v i x). This strategy for computing A x can provide considerably savings when the number of nonzero σ i values is relatively small. Furthermore, we can ignore small values of σ i, effectively truncating this sum to approximate A x with less work. Similarly, from 6.2.1 we can write the pseudoinverse of A as: A + v i u i =. σ σ i =0 i Obviously we can apply the same trick to evaluate A + x, and in fact we can approximate A + x by only evaluating those terms in the sum for which σ i is relatively small. In practice, we compute the singular values σ i as square roots of eigenvalues of A A or AA, and methods like power iteration can be used to reveal a partial rather than full set of eigenvalues. Thus, if we are going to have to solve a number of least-squares problems A x i bi for different bi and are satisfied with an approximation of x i, it can be valuable first to compute the smallest σ i values first and use the approximation above. This strategy also avoids ever having to compute or store the full A + matrix and can be accurate when A has a wide range of singular values. Returning to our original notation A = UΣV, our argument above effectively shows that a potentially useful approximation of A is à U ΣV, where Σ rounds small values of Σ to zero. It is easy to check that the column space of à has dimension equal to the number of nonzero values on the diagonal of Σ. In fact, this approximation is not an ad hoc estimate but rather solves a difficult optimization problem post by the following famous theorem (stated without proof): Theorem 6.1 (Eckart-Young, 1936). Suppose à is obtained from A = UΣV by truncating all but the k largest singular values σ i of A to zero. Then à minimizes both A à Fro and A à 2 subect to the constraint that the column space of à have at most dimension k. 5

6.2.3 Matrix Norms Constructing the SVD also enables us to return to our discussion of matrix norms from 3.3.1. For example, recall that we defined the Frobenius norm of A as A 2 Fro a 2 i. i If we write A = UΣV, we can simplify this expression: A 2 Fro = A e 2 since this product is the -th column of A = UΣV e 2, substituting the SVD = e VΣ 2 V e since x 2 = x x and U is orthogonal = ΣV 2 Fro by the same logic = VΣ 2 Fro since a matrix and its transpose have the same Frobenius norm = VΣ e 2 = σ 2 V e 2 by diagonality of Σ = σ 2 since V is orthogonal Thus,the Frobenius norm of A R m n is the sum of the squares of its singular values. This result is of theoretical interest, but practically speaking the basic definition of the Frobenius norm is already straightforward to evaluate. More interestingly, recall that the induced twonorm of A is given by A 2 2 = max{λ : there exists x R n with A A x = λ x}. Now that we have studied eigenvalue problems, we realize that this value is the square root of the largest eigenvalue of A A, or equivalently A 2 = max{σ i }. In other words, we can read the two-norm of A directly from its eigenvalues. Similarly, recall that the condition number of A is given by cond A = A 2 A 1 2. By our derivation of A +, the singular values of A 1 must be the reciprocals of the singular values of A. Combining this with our simplification of A 2 yields: cond A = σ max σ min. This expression yields a strategy for evaluating the conditioning of A. Of course, computing σ min requires solving systems A x = b, a process which in itself may suffer from poor conditioning of A; if this is an issue, conditioning can be bounded and approximated by using various approximations of the singular values of A. 6

6.2.4 The Procrustes Problem and Alignment Many techniques in computer vision involve the alignment of three-dimensional shapes. For instance, suppose we have a three-dimensional scanner that collects two point clouds of the same rigid obect from different views. A typical task might be to align these two point clouds into a single coordinate frame. Since the obect is rigid, we expect there to be some rotation matrix R and translation t R 3 such that that rotating the first point cloud by R and then translating by t aligns the two data sets. Our ob is to estimate these two obects. If the two scans overlap, the user or an automated system may mark n corresponding points that correspond between the two scans; we can store these in two matrices X 1, X 2 R 3 n. Then, for each column x 1i of X 1 and x 2i of X 2, we expect R x 1i + t = x 2i. We can write an energy function measuring how much this relationship holds true: E R x 1i + t x 2i 2. i If we fix R and minimize with respect to t, optimizing E obviously becomes a least-squares problem. Now, suppose we optimize for R with t fixed. This is the same as minimizing RX 1 X t 2 Fro, where the columns of X t 2 are those of X 2 translated by t, subect to R being a 3 3 rotation matrix, that is, that R R = I 3 3. This is known as the orthogonal Procrustes problem. To solve this problem, we will introduce the trace of a square matrix as follows: Definition 6.3 (Trace). The trace of A R n n is the sum of its diagonal: tr(a) a ii. i It is straightforward to check that A 2 Fro = tr(a A). Thus, we can simplify E as follows: RX 1 X t 2 2 Fro = tr((rx 1 X t 2) (RX 1 X t 2)) = tr(x 1 X 1 X 1 R X t 2 X t 2 RX 1 + X t 2 X 2) = const. 2tr(X t 2 RX 1) since tr(a + B) = tr A + tr B and tr(a ) = tr(a) Thus, we wish to maximize tr(x2 t RX 1) with R R = I 3 3. In the exercises, you will prove that tr(ab) = tr(ba). Thus our obective can simplify slightly to tr(rc) with C X 1 X2 t. Applying the SVD, if we decompose C = UΣV then we can simplify even more: tr(rc) = tr(ruσv ) by definition = tr((v RU)Σ) since tr(ab) = tr(ba) = tr( RΣ) if we define R = V RU, which is also orthogonal = σ i r ii since Σ is diagonal i Since R is orthogonal, its columns all have unit length. This implies that r ii 1, since otherwise the norm of column i would be too big. Since σ i 0 for all i, this argument shows that we can maximize tr(rc) by taking R = I 3 3. Undoing our substitutions shows R = V RU = VU. More generally, we have shown the following: 7

Theorem 6.2 (Orthogonal Procrustes). The orthogonal matrix R minimizing RX Y 2 is given by VU, where SVD is applied to factor XY = UΣV. Returning to the alignment problem, one typical strategy is an alternating approach: 1. Fix R and minimize E with respect to t. 2. Fix the resulting t and minimize E with respect to R subect to R R = I 3 3. 3. Return to step 1. The energy E decreases with each step and thus converges to a local minimum. Since we never optimize t and R simultaneously, we cannot guarantee that the result is the smallest possible value of E, but in practice this method works well. 6.2.5 Principal Components Analysis (PCA) Recall the setup from 5.1.1: We wish to find a low-dimensional approximation of a set of data points, which we can store in a matrix X R n k, for k observations in n dimensions. Previously, we showed that if we are allowed only a single dimension, the best possible direction is given by the dominant eigenvector of XX. Suppose instead we are allowed to proect onto the span of d vectors with d min{k, n} and wish to choose these vectors optimally. We could write them in an n d matrix C; since we can apply Gram-Schmidt to any set of vectors, we can assume that the columns of C are orthonormal, showing C C = I d d. Since C has orthonormal columns, by the normal equations the proection of X onto the column space of C is given by CC X. In this setup, we wish to minimize X CC X Fro subect to C C = I d d. We can simplify our problem somewhat: X CC X 2 Fro = tr((x CC X) (X CC X)) since A 2 Fro = tr(a A) = tr(x X 2X CC X + X CC CC X) = const. tr(x CC X) since C C = I d d = C X 2 Fro + const. So, equivalently we can maximize C X 2 Fro ; for statisticians, this shows when the rows of X have mean zero that we wish to maximize the variance of the proection C X. Now, suppose we factor X = UΣV. Then, we wish to maximize C UΣV Fro = C Σ Fro = Σ C Fro by orthogonality of V if we take C = CU. If the elements of C are c i, then expanding this norm yields Σ C 2 Fro = σi 2 c 2 i. i By orthogonality of the columns of C, we know i c 2 i = 1 for all and, since C may have fewer than n columns, c 2 i 1. Thus, the coefficient next to σ2 i is at most 1 in the sum above, so if we sort such that σ 1 σ 2, then clearly the maximum is achieved by taking the columns of C to be e 1,..., e d. Undoing our change of coordinates, we see that our choice of C should be the first d columns of U. 8

We have shown that the SVD of X can be used to solve such a principal components analysis (PCA) problem. In practice the rows of X usually are shifted to have mean zero before carrying out the SVD; as shown in Figure NUMBER, this centers the dataset about the origin, providing more meaningful PCA vectors u i. 6.3 Problems 9