A M×N matrix is a 2D array with M rows and N columns.
1D array - row vector or column vector.
Some special matrix: diagonal - only diagonal is non 0. Identiy - diagonal with all 1. Sparse (lots of 0), and symmetric (square, a(i,j) = a(j,i) for all i and j).
Tensor
Array of numbers, 0 dimension- scalar, 1 d - vector, 2d - matirx, 3 or higher is usually a tensor.
Matrix operation: element by element vector operations - addition and subtractions. Size must be the same for all operands.
Matrix and scalar operation, multiply or divide.
Inner/outer product.
Let A=[aij] be a M×N matrix and b=[bn] be a N×1 column vector.
Inner product: Let x and y be N×1 vectors:
xTy=∑n=1Nxnyn
Result in a scalar, both x and y have the same dimension.
outer product:
xM×1y1×NT=[xmyn]M×N A M×N matrix.
Results in a matrix.
x and y do not need to be same dimension
Matrix vector product:
c=Ab=[ci]i=1M where ci=∑j=1Naijbj=aiTb,1≤i≤M
Matrix matrix product: dimension need to match (column of first and row of second)
C=AM×NBN×P⟹cm,p=∑n=1Namnbnp
Vector Space
x and y are linearly independent if ax+by=0 implies a=b=0. Otherwise, y=−(a/b)x meaning y is scaled version of x.
If {vk}are Klinearly independe t vectors, and each vk is a M(≥K)×1 vector, then {vk}span a K dim subspace in RM.
x and y are orthogonal if xTy=0.
if {vk} are mutually orthogonal, they can be a set of basis of the subspace.
Rank
rank of a matrix is the number of linear independent column vectors, or linear independnet row vectors.
rank(AM×N)≤min{M,N}
A matrix is full rank if its rank equal to the smaller of its column numbers or row numbers. Otherwise, a matrix is rank-deficient.
Vector Norms
L2: ∣∣x∣∣2=xTx=(∑i=1Nxi2)1/2 x is a unit vector if ∣∣x∣∣2=1
Angle: cosθ=(xTy)/(∣∣x∣∣⋅∣∣y∣∣)
L1: ∣∣x∣∣1=∑k=1m∣xk∣
L infinity: ∣∣x∣∣∣∞=max1≤k≤m∣xk∣
Hyperplane
A hyperplane in an n-dimensional vector space is a (n-1) dim subspace. In the Euclidean space,a plane is a hyperplane in a 3D space, a line is a hyper plane in a 2D space.
Hyperplane function {x;x∈Rn,wTx+b=∑i=1nwixi+b=0}
A hyperplane partition the space into two half spaces:
{x;x∈Rn,wTx=∑i=1nwixi<b} and {x;x∈Rn,wTx=∑i=1nwixi>b}
Distance from a point to a hyperplane
r=−(wTx∗+b)/∣w∣=−g(x∗)/∣w∣
SVD
AM×N=UM×rΣr×rVr×NT=∑i=1rσiuiviT
Singular value: σ1≥σ2≥…,≥σr≥0, r≤min(M,N)
UTU=Ir, VTV=Ir, UUM×MT=I, VVN×NT=I
umTun=vmTvn={10m=nm=n
Number of non-zero singular values = rank of matrix.
SVD is the procedure for PCA.
Eigenvalue Decomposition
A symmetric matrix may be decomposed as:
AN×N=VΛVT=∑n=1NλnvnvnT
ΛN×N=diag{λ1,…,λN}, λn eigenvalue
vn eigenvector Av=λv⟹(A−λI)v=0
VVT=VTV=I⟹vmTvn={10m=nm=n
A is positive definite iff all eigenvalues are posisitve
If A is Hermitian (A^H = complex conjugate transpose of A) then all eigenvalues are real numbers.