Singular vector decomposition is one of the highlights of linear algebra.
Review of Linear Transformation
Before diving into the topic, we have a brief review of linear transformation. Given a matrix A∈Rm×n with rank r, we can view it as a linear transformation from f:Rn→Rm defined as
f(x)=Ax,∀x∈Rn.
It maps a vector in the row space, i.e., the subspace spanned by row vectors of A, to a vector in the column space, the subspace spanned by column vectors of A.
Define
S(AT)={∑i=1nλiA[i,:]:λi∈R,∀i∈[n]}, which we call the row space of A.
N(AT)={x∈Rm,s.t.,Ax=0}, the subspace perpendicular to S(AT).
S(A)={∑i=1mλiA[:,i]:λi∈R,∀i∈[m]}, the columns space of A.
N(A) the space perpendicular to S(A).
Note that S(AT) and S(A) has the same dimension r. For any x∈Rn, we can write x=y+z, such that y∈S(AT) and z∈N(AT). The operation Ax=Ay+Az, takes the y component to a vector in S(A) and the z component to point 0, as illustrated by the figure.
Singular Vector Decomposition
Singular vector decomposition aims to find
an orthonormal basis {v1,v2,...,vr} for S(AT),
and an orthogonal base {u1,u2,...,ur} for S(A),
such that f(vi)=Avi=σiui for all i∈[r] and σ1≥σ2≥...≥σr>0.
When restricted to the sets {v1,v2,...,vr} and {u1,u2,...,ur}, f is a bijection.
If we write V=[v1,v2,...,vr],
Σ=σ1σ2...σr
and U=[u1,u2,...,ur], then
AV=UΣ.
As the columns of V are orthonormal vectors, it is invertible and V−1=VT. Hence
A=UΣV−1=UΣVT
Equivalently, it holds that
A=σ1u1v1T+σ2u2v2T+...+σrurvrT.
Further,
ATA=VΣ2VT,AAT=UΣ2UT.
which implies that
ATAV=VΣ2,AATU=UΣ2.
The vi's and ui's are eigenvectors of ATA and AAT respectively.
EXISTENCE
The key is ATA, which is semi-positive. Since
ATAx=0⇔xATAx=0⇔Ax=0,
ATA and A has the rank r, the same null space and hence the same row space. Further, as ATA is semi-positive, it has r positive eigenvalue. Denote the eigenvalues of ATA in decreasing order as λ1≥λ2≥...≥λr>0 and the corresponding (unit length) eigenvectors as v1,v2,...,vr. The vi's are orthogonal, as
For i=j, viTATAvj=λiviTvj=λjviTvj. As λi=λj, viTvj=0.
They constitute an orthogonal base of the row space of ATA and the row space A.
Now we use the vi's to search for ui's as follows: let σ=λi, we claim that
ui≐σi1Avi,∀i∈[r]
are orthonormal.
The ui's are orthogonal: uiTuj=σiσj1viTATAvj=σiσjσj2viTvj=0
The ui's are unite vectors: uiTui=σi21viTATAvi=1
Hence ui's constitutes an orthonormal basis. As the columns of A has dimension r, the ui's covers the entire columns space. This completes the proof. ■
GEOMETRIC INTERPRETATION
To understand the geometry of SVD, we first extend the matrix V to an orthogonal base in Rn and U to an orthogonal base in Rm. By adding proper zero rows and columns to Σ, we still have A=UΣVT.
Now, the transformation f(x) is decomposed into three steps:
x→VTx→Σ(VTx)→U(ΣVTx)
It suffices to under the effect of multiplying an orthogonal matrix V. It is indeed a rotation. To see this, multiply V by ei gives vi, i.e., Vei=vi, for all for i∈[n]. Therefore, V takes the orthogonal base I=[e1,e2,...,en] to the orthogonal base V=[v1,v2,...,vn].
Note that the inverse V−1 of V is also an orthogonal matrix and hence a rotation. Indeed it rotates the orthogonal base V=[v1,v2,...,vn] back to I=[e1,e2,...,en]. To understand this, observe that V−1=VT. For arbitrary vi, we have VTvi=ei.
Therefore, VTx corresponds to a rotation, in the reverse direction to the one defined by V.
Next, the matrix Σ scales the i-th dimension of VTx by σi, for all i∈[n]. Combined with the first step, if x=vi, then it is first rotation to the direction ei, then scaled by a factor σi.
Finally, U is an orthogonal matrix and corresponds to another rotation, which take ei∈Rm to a vector ui.
Corollary: Define the Frobenius norm of a matrix A as
∥A∣F=i,j∑ai,j2
Then ∥A∥F2=∥Σ∥2=∑i=1rσi2.
Proof: Note that rotating the vectors do not change their distance from the origin. Recall that UT and V are both rotations. Hence ∥A∥F2=∥AV∥F2=∥UTAV∥F2=∥UTUΣVTV∥F2=∥Σ∥F2.
□.
APPLICATIONS
An important property of the vi is that
v1=argmaxv∈Rn,∥v∥=1∥Av∥.
v2=argmaxv∈Rn,∥v∥=1,v⊥v1∥Av∥.
...
vr=argmaxv∈Rn,∥v∥=1,v⊥v1,v⊥v2,...,v⊥vr−1∥Av∥
Proof: For any v∈Rn,∥v∥=1, we can write v=∑i=1naivi, where ∑i=1nai2=1, since vi's are an orthogonal base. Then
∥Av∥2=xTATAx=xTVΣUTUΣVTx=∥ΣVTx∥2=i=1∑rai2σi2
which is maximized to σ12 when a1=1 and ai=0,i≥2. Hence (1) is proved.
Similarly, when ∥v∥=1,v⊥v1,v2,...,vk for some k<r, then a1=a2=...ak=0, and v=∑i=k+1raivi.
∥Av∥2=i=k+1∑rai2σi2
which achieves maximum when ak+1=1 and ai=0,i>k+1. In this case v=vk+1.
Best Fit k subspace
An implication is that, the subspace space Vk spanned by (v1,v2,...,vk), is the best k-dimension subspace of Rn that fits the row vectors of A, namely, A[1,:],A[2,:],...,A[m,:]. Here fits mean the sum of the square of the perpendicular distance from the row vector to their projections on the subspace is minimized. Denote S any subspace of Rn, then for v∈Rn, we can decompose v into two part: the part vS that is within S and the part vS⊥ perpendicular to S. Then
∥v∥2=∥vS∥2+∥vS⊥∥2
Minimizing ∥vS⊥∥2 is equivalent to maximizing ∥vS∥2. The subspace space by (v1,v2,...,vk) is the subspace that maximize the sum of the squares of the projections of row vectors to the subspace.
We prove this by induction. When k=1, the proof holds trivially by the definition of v1. In particular, Av1 is the lengths of the projections of the row to the line that go through v1, since v1 is a unit vector. Further, the corresponding projected vectors in Rn are
Av1v1T=σ1u1v1T
For general k, by induction hypothesis Vk−1 is the best k−1 dimension space that fit rows of A. Denote N(Vk−1) the subspace that is perpendicular to Vk−1, which has dimension n−k+1. For any k dimensional subspace S∩N(Vk−1)=∅, since dim(S)+dim(N(Vk−1))=k+n−k+1≥n. Let sk∈S∩N(Vk−1) be a unit vector. By the definition of vk, we have
∥Avk∥2≥∥Ask∥2
Now we can extend sk to a base of S, denoted as s1,s2,...,sk. By induction hypothesis, it holds
i=1∑k−1∥Avi∥2≥i=1∑k−1∥Asi∥2
Hence
i=1∑k∥Avi∥2≥i=1∑k∥Asi∥2
But the former is exactly sum of the squares of the lengths of the projections to Vk and the later is the one to S. Finally, we mention that the projection of A to Vk is given by
Ak=i=1∑kσiuiviT
Corollary 1.
For any rank k matrix B, we have
∥A−Ak∥F≤∥A−B∥F
Intuitively, if we view square root of the sum of square distance of row vectors to the origin (note that the origin can be viewed as a zero dimension subspace.)
Corollary 2. Define the 2-norm of a matrix A as
∥A∥2=σ1=v∈Rn,∥v∥=1max∥Av∥
The 2-norm is the square root of the maximum sum of squares of the projections of the row vectors to a one dimension subspace. Then an implication of the SVD is that, for any rank k matrix B, we have
∥A−Ak∥2≤∥A−B∥2
Proof: First note that for v=∑i=1raivi, such that ∑i=1kai2=1,
∥(A−Ak)v∥=i=k+1∑raiσi
it is maximized when ak+1=1 and ∥A−Ak∥2=σk+1. Now, as dim(Ak+1)+dim(N(BT))=k+1+n−k≥n, ∃v∈Rn, such that Bv=0 and v=∑i=1k+1aivi and ∥v∥=1. Now
∥A−B∥2≥∥(A−B)v∥=∥Av∥=i=1∑k+1ai2σi2≥σk+1
which finishes our proof.
Computing SVD
If suffices to compute the eigenvectors and eigenvalues of ATA, i.e., σi2's and vi's. In the simplest case, σ1>σ2≥σ3≥...≥σr, then we can take powers of ATA,
The second part converges to 0 as k→∞. Then for any vector v that is not perpendicular to v1, we have
klimσ12k1(ATA)kv=v1(v1Tv)=(v1Tv)v1
which is a multiple of v1. Normalizing the vector recovers v1.
When there is a tie of the largest eigenvalues, that is σ1=σ2=...=σt for some t<r, and suppose that v is not perpendicular to v1,v2,...,vt simultaneously, then
klimσ12k1(ATA)kv=the projection of v to Vt
Suppose we are satisfied with this result, we still need to address two problems.
We use σ12k to normalize the resulting vector, which is unknown.
How can we find a vector v that is not perpendicular to all v1,..,vt simultaneously, i.e., its projection to Vt is not zero.
We defer the discussion of the first issue. As for the second issue, we tackle the problem for picking a vector v uniformly at random from the n-dimension unit ball, and then normalize it by $v / \Vert v\Vert $, in the hope that it is a "good" vector.
Lemma: With probability at least 1/2, that vTv1≥1/n.
Proof: By symmetry of the n-dimension unit ball, it suffices to show that for an arbitrary given fixed direction, the projection of v to that direction is at least 1/4n with probability 1/2. For convenience, we choose this direction to be e1.
Denote the volume of an n-dimensional unit ball as V(n).
Now, we would like to use two cylinders to estimate the probability of ∣e1Tv∣/∥v∥≤4n1.
Note that the points {v} inside the ball with e1Tv/∥v∥≤4n1 is completely contained in a cylinder centered in the equator, with radius one and height 4n1 that is parallel to e1. Its volume is given by 4n1V(n−1). Hence:
Pr[∣vTe1∣≤4n1]≤V(n)24n1V(n−1)
On the other hand, we can use a cylinder centered at the equator to lower bound the volume of n-dimension unit ball. The cylinder is inside the ball, with height 2n1 and radius (1−(n1)2)1/2 . Therefore,
Note that (1−n1)n increases with n, and for n≥2, (1−n1)n≥41 and (1−n1)n/2≥21
Pr[vTe1≤4n1]≤V(n)4n1V(n−1)≤21
□
Theorem After ϵ1lnϵn iterations, we can obtain a vector whose component that is perpendicular to Vt is at most ϵ fraction of its square length, with probability at least 21.
Proof: If σi<(1−ϵ)σ1, then
∑j=1kσ12kσi2k≤σ1σi2k≤(1−ϵ)2k
Denote σ1=σ2=...=σt for some t<r the largest singular values. By the previous lemma, we pick a v from the unit ball at random, and take $v \leftarrow v / \Vert v\Vert $. Denote v=∑i=1naivi, then with probability at least 1/2 we have ∑i=1tai2≥4n1. On the other hand, v is a unit vector, hence ∑i=1nai2=1. Therefore, ∑i=t+1nai2≤1−16n1
If we take k=O(ϵ1lnϵn), then the second term is at most ϵ fraction of the first term.
Remark: picking a point uniformly at random can be done as follows: first pick a point v uniformly at random from the high dimension cube: [−1,1]n, then checks whether the point is inside the ball (∥v∥<1). This however, could suffers from efficiency problem as the volume of the ball approaches to 0 as the number of dimension increases. More efficient sampling method is needed. But it is not the current focus of this article.
Reference
[1]. GILBERT STRANG, Introduction to Linear Algebra.
[2]. Venkatesan Guruswami and Ravi Kannan, Note 2, Singular Value Decomposition, 15-496/15-859X: Computer Science Theory for the Information Age, Spring 2012, CMU