Matrix Decompositions and Spectral MethodsIntroduction and ContextMatrices provide the central language for representing structured data, linear transformations, systems of equations and statistical relationships. In data science, a data matrix may contain observations by variables, an image may be represented as a matrix of pixel intensities, and a recommender system may store user–item interactions in a sparse matrix. Matrix decompositions rewrite a matrix as a product of simpler matrices. This often exposes hidden structure, reduces computational cost and improves numerical stability. Spectral methods are based primarily on eigenvalues and eigenvectors. They are useful when the geometry of a problem is determined by a symmetric matrix, such as a covariance matrix, a graph Laplacian or a kernel matrix. Singular value decomposition extends these ideas to every real or complex matrix and is especially important for dimensionality reduction, latent-factor modelling, information retrieval and recommendation systems. This chapter develops determinants, eigen-analysis, positive-definite matrices, eigendecomposition, singular value decomposition (SVD), pseudoinverses and their practical use in postgraduate data science. Learning ObjectivesBy the end of this chapter, you should be able to: - Interpret determinants, eigenvalues and eigenvectors geometrically and algebraically.
- Distinguish positive-definite, positive-semidefinite and indefinite matrices.
- Compute and interpret eigendecompositions of suitable matrices.
- Explain and use the singular value decomposition.
- Construct the Moore–Penrose pseudoinverse and solve least-squares problems.
- Apply spectral methods to principal component analysis, latent-factor models and recommendation.
- Evaluate approximation error, rank selection and numerical conditioning.
- Identify limitations, modelling risks and responsible-use issues in spectral methods.
1. Matrix Foundations for Data ScienceA matrix A ∈ ℝm×n is a rectangular array with m rows and n columns. Its element in row i and column j is written aij. A vector is a matrix with one column or one row. Matrix multiplication AB is defined when the number of columns of A equals the number of rows of B. The transpose AT interchanges rows and columns. A square matrix is symmetric if A = AT. The identity matrix In has ones on its main diagonal and zeros elsewhere. A matrix is invertible if there exists A-1 such that AA-1 = A-1A = I. Inversion is defined only for square, nonsingular matrices; in data science it is usually preferable to solve systems directly rather than explicitly forming an inverse. DeterminantsThe determinant is a scalar defined for a square matrix. For a 2 × 2 matrix, det(A) = | a b | | c d | = ad − bc For an n×n matrix, the determinant can be defined recursively by cofactor expansion, although numerical software generally uses factorisation-based algorithms. Important properties include: - det(AB) = det(A)det(B).
- det(AT) = det(A).
- A is invertible if and only if det(A) ≠ 0.
- Multiplying a matrix by a scalar c gives det(cA) = cn det(A) for an n×n matrix.
Geometrically, the absolute determinant is the factor by which the linear transformation changes volume. A negative determinant also reverses orientation. In statistical modelling, determinants appear in multivariate Gaussian densities and covariance-volume calculations. However, a determinant close to zero is not by itself a reliable numerical measure of instability, because its scale depends strongly on matrix dimension and units. The condition number is usually more informative. 2. Eigenvalues and EigenvectorsFor a square matrix A ∈ ℝn×n, a nonzero vector v is an eigenvector with eigenvalue λ if Av = λv Thus, the transformation A changes the length and possibly direction of v but does not rotate it to a different line. Rearranging gives (A − λI)v = 0 A nonzero solution exists only when A − λI is singular: det(A − λI) = 0 This equation is the characteristic equation. Its roots are the eigenvalues. The eigenspace associated with λ is the null space of A − λI. Algebraic multiplicity counts how many times an eigenvalue occurs as a root; geometric multiplicity is the dimension of its eigenspace. A matrix is diagonalizable when it has a basis of eigenvectors. Repeated eigenvalues do not automatically prevent diagonalization. For a real symmetric matrix, the spectral theorem guarantees an orthonormal eigenbasis. Therefore, A = QΛQT where Q is orthogonal, QTQ = I, and Λ is diagonal with real eigenvalues. This decomposition is central in covariance analysis and PCA. Worked Example: A Symmetric MatrixConsider A = [ 2 1 ] [ 1 2 ] The characteristic polynomial is det(A − λI) = (2 − λ)2 − 1 = λ2 − 4λ + 3 The eigenvalues are λ1 = 3 and λ2 = 1. For λ1 = 3, an eigenvector is (1,1)T; its unit version is q1 = (1/√2)(1,1)T. For λ2 = 1, an eigenvector is (1,−1)T; its unit version is q2 = (1/√2)(1,−1)T. Hence Q = [q1\ q2] is orthogonal and Λ = diag(3,1). The direction q1 is stretched by a factor of 3, while q2 is stretched by a factor of 1. For a general nonsymmetric matrix, eigenvalues may be complex, eigenvectors need not be orthogonal and a complete eigenbasis may not exist. Consequently, eigendecomposition is not the universal factorisation for data matrices; SVD is. 3. Positive-Definite MatricesA real symmetric matrix A is positive definite (PD) if xTAx > 0 for every nonzero x ∈ ℝn It is positive semidefinite (PSD) if xTAx ≥ 0 for every x. A symmetric matrix is PD exactly when all its eigenvalues are strictly positive; it is PSD exactly when all eigenvalues are nonnegative. Equivalent tests for a real symmetric matrix include: - PD if and only if all eigenvalues are positive.
- PD if and only if all leading principal minors are positive (Sylvester’s criterion).
- PD if and only if it has a Cholesky factorisation A = LLT, where L is lower triangular with positive diagonal entries.
Positive-definite matrices define inner products and ellipsoidal quadratic forms. If Σ is a covariance matrix, positive semidefiniteness is required because variances of all linear combinations must be nonnegative: Var(aTX) = aTΣa ≥ 0 A covariance matrix is often singular when variables are linearly dependent. Adding a small ridge term αI, with α > 0, produces Σ + αI, which is positive definite when Σ is PSD. This is regularisation, not a claim that the original covariance structure was nonsingular. 4. Spectral Geometry and Quadratic FormsIf a symmetric matrix has eigendecomposition A = QΛQT, define y = QTx. Since Q is orthogonal, xTAx = yTΛy = ∑i=1n λi yi2 This expression makes definiteness transparent. It also shows that the eigenvectors provide principal directions of the quadratic form, while eigenvalues determine curvature or scale along those directions. The spectral norm of a symmetric matrix is the largest absolute eigenvalue. For a PSD matrix it is simply the largest eigenvalue. The trace equals the sum of eigenvalues: tr(A) = ∑i=1n λi The determinant equals their product: det(A) = ∏i=1n λi These identities apply to square matrices and are particularly useful for covariance matrices: the trace is total variance, while the determinant is proportional to squared volume of the covariance ellipsoid. 5. Singular Value DecompositionFor every real matrix A ∈ ℝm×n, there exist orthogonal matrices U ∈ ℝm×m and V ∈ ℝn×n and a rectangular diagonal matrix Σ such that A = UΣVT The diagonal entries σ1 ≥ σ2 ≥ … ≥ σr ≥ 0 are the singular values, where r = rank(A). The columns of U are left singular vectors and those of V are right singular vectors. A compact SVD retains only the nonzero singular directions: A = UrΣrVrT The singular values satisfy ATA vi = σi2 vi, AAT ui = σi2 ui Thus, right singular vectors are eigenvectors of ATA, and left singular vectors are eigenvectors of AAT. Unlike direct eigendecomposition, SVD is defined for rectangular, rank-deficient and nonsymmetric matrices. It is also numerically more reliable than explicitly forming ATA, which squares the condition number. Geometric InterpretationFor a unit vector vi, Avi = σi ui The matrix maps orthogonal input directions vi to orthogonal output directions ui, scaling them by σi. The image of the unit sphere is an ellipsoid whose semiaxis lengths are the singular values. Zero singular values correspond to directions lost by the transformation. Eckart–Young OptimalityThe best rank-k approximation to A in both the Frobenius norm and the spectral norm is obtained by truncating its SVD: Ak = UkΣkVkT For the Frobenius norm, ||A − Ak||F2 = ∑i=k+1r σi2 where ||A||F = √(∑i,jaij2). The spectral-norm error is ||A − Ak||2 = σk+1. These results assume an exact mathematical SVD; practical data also require a judgement about noise, scale and interpretability. 6. Principal Component AnalysisSuppose X ∈ ℝn×p contains n observations and p variables. PCA normally begins by centring each column: Xc = X − 1n μT where μ is the vector of column means and 1n is an n-element vector of ones. Scaling to unit variance may also be appropriate when variables have different units or vastly different variances. The sample covariance matrix is S = (1/(n−1))XcTXc PCA finds eigenvectors of S. Equivalently, if Xc = UΣVT then the columns of V are principal directions and the principal scores are Z = XcV. The variance of component i is λi = σi2/(n−1) The explained-variance ratio of the first k components is EVRk = (∑i=1k λi)/(∑i=1r λi) = (∑i=1k σi2)/(∑i=1r σi2) PCA is an unsupervised linear method. It maximises variance, not predictive accuracy, fairness or causal relevance. Components are identifiable only up to sign: v and −v represent the same axis. With repeated eigenvalues, the individual directions within the repeated subspace are not uniquely identified. Choosing the Number of ComponentsCommon approaches include a target explained-variance threshold, a scree plot, cross-validation for downstream performance, information criteria and domain constraints. Retaining 95% of variance is not universally optimal: low-variance variables may be important for prediction, and high-variance directions may reflect measurement scale or nuisance variation. 7. Pseudoinverses and Least SquaresWhen A is rectangular or singular, an ordinary inverse does not exist. The Moore–Penrose pseudoinverse A^+ is defined uniquely by the four conditions: AA^+A = A, A^+AA^+ = A^+, (AA^+)T = AA^+, (A^+A)T = A^+A If A = UΣVT, then A^+ = VΣ^+UT where Σ^+ is formed by transposing Σ and replacing each nonzero singular value σi with 1/σi. Singular values equal to zero remain zero. For an overdetermined system Ax ≈ b, the least-squares solution minimises ||Ax − b||22 The minimum-norm least-squares solution is x^* = A^+b If A has full column rank, this reduces algebraically to x^* = (ATA)-1ATb but this normal-equation expression should generally not be computed literally because it can worsen numerical conditioning. QR or SVD-based solvers are preferred. For an underdetermined system with infinitely many solutions, A^+b is the solution with minimum Euclidean norm. The matrix AA^+ projects onto the column space of A, while A^+A projects onto its row space. Numerical Stability and ConditioningThe 2-norm condition number of a nonzero matrix is κ2(A) = σmax/σmin where σmin is the smallest nonzero singular value for a full-rank problem. A large condition number means that small input or rounding errors can cause large changes in the solution. If σmin = 0, the matrix is rank-deficient and the condition number is infinite. The normal equations effectively square the condition number: κ2(ATA) = κ2(A)2 for full-column-rank A. This explains why forming ATA can be unstable. In SVD-based pseudoinversion, very small singular values may be truncated using a tolerance. This creates a controlled bias in exchange for lower variance and better stability. 8. Latent-Factor Modelling and RecommendationMany data matrices are approximately low rank. A user–item rating matrix R can be modelled as R ≈ PQT where P ∈ ℝm×k contains latent user factors, Q ∈ ℝn×k contains latent item factors and k is much smaller than both dimensions. The predicted rating is r̂ui = puTqi A regularised objective over observed ratings Ω is minP,Q ∑(u,i)∈Ω(rui − puTqi)2 + λ(||P||F2 + ||Q||F2) where λ ≥ 0 controls shrinkage. Bias terms may be added for the global mean, user tendencies and item tendencies. Alternating least squares and stochastic-gradient methods are common optimisation approaches. SVD applied directly to a complete, centred matrix gives an optimal low-rank approximation under squared reconstruction error. Real recommendation data are usually sparse and missingness is not random. Treating every unobserved entry as a zero or a negative preference can introduce severe bias. A model should distinguish an unobserved interaction from an observed dislike and should evaluate using temporally separated, user-aware validation data. 9. Graph Spectral MethodsFor a weighted undirected graph, let A be the adjacency matrix and D the diagonal degree matrix, with Dii = ∑j Aij. The unnormalised graph Laplacian is L = D − A For any vector x, xTLx = (1/2)∑i,j Aij(xi − xj)2 ≥ 0 so L is PSD. The multiplicity of eigenvalue zero equals the number of connected components. The smallest nonzero eigenvectors can reveal community structure and are used in spectral clustering. Normalised alternatives include D-1/2LD-1/2, provided the relevant degrees are positive. Graph-based dimensionality reduction and semi-supervised learning use these eigenvectors to encourage nearby or strongly connected points to receive similar representations. Their quality depends on the graph construction, distance metric, scale parameter and robustness to noisy or unfair connectivity patterns. 10. Detailed Application: PCA for Sensor-Fault MonitoringBackgroundConsider an illustrative manufacturing process with 1,000 time-window observations and 12 sensors measuring temperature, pressure, flow and vibration. The goal is to compress the measurements and detect unusual operating states. ProblemThe sensors are correlated, measured in different units and affected by occasional faults. A monitoring team needs a lower-dimensional representation that preserves normal operating variation while identifying observations that do not conform to the learned structure. Analysis and ApproachFirst, engineers remove impossible readings and decide how to treat missing values without using future information. They centre the training observations. Because units differ substantially, they standardise each sensor using training-set means and standard deviations. They then compute an SVD of the scaled matrix rather than explicitly forming a covariance matrix. Suppose the first four singular values are 41.2, 18.6, 11.4 and 8.0, and the total sum of squared singular values is 2,500. The variance retained by four components is (41.2² + 18.6² + 11.4² + 8.0²)/2500 = (1697.44 + 345.96 + 129.96 + 64)/2500 = 2237.36/2500 ≈ 0.895 Thus, four components retain approximately 89.5% of the scaled variation. The team examines loadings rather than assigning automatic physical meanings to components. A reconstruction residual for observation x is e = x − x̂, x̂ = xVkVkT when x is represented in centred coordinates and Vk contains the retained right singular vectors. A large residual may indicate a fault, a new operating regime or a data-quality problem; it is not automatically evidence of equipment failure. OutcomeThe reduced representation supports visual monitoring and lowers the cost of downstream anomaly models. Thresholds are calibrated on historical normal data and checked across operating conditions. The system is deployed with an audit trail, human review and a fallback to raw sensor diagnostics. Learning Points- Scaling decisions determine which directions PCA considers important.
- Variance retention is a descriptive criterion, not a guarantee of fault-detection performance.
- Components require domain interpretation and may change after process redesign.
- Validation must respect time order and avoid leakage from future faults.
- Anomaly alerts should support engineering judgement rather than replace it.
11. Limitations, Governance and Best PracticesStatistical and Computational LimitationsPCA and truncated SVD are linear. Nonlinear manifolds may require kernel methods, autoencoders or other nonlinear approaches, each with additional assumptions and interpretability costs. Outliers can dominate covariance estimates. Robust PCA and robust covariance estimators may help, but they also require tuning and may fail under adversarial contamination. Singular vectors can be unstable when singular values are close. A small perturbation in the data may change individual vectors substantially even when the associated subspace remains stable. Rank selection is therefore uncertain, especially when the singular-value spectrum has no clear gap. SVD can be expensive for very large matrices. Randomised and truncated SVD algorithms reduce computational cost by approximating dominant subspaces. Their accuracy should be checked using reconstruction error, residual tests and reproducibility across random seeds. Governance and Ethical IssuesDimensionality reduction can obscure protected attributes without removing their information. A latent factor may encode gender, ethnicity, disability, socioeconomic status or other sensitive characteristics through correlated variables. Removing explicit identifiers is not sufficient to ensure fairness. Recommendation systems can amplify popularity bias, reduce exposure for minority creators and create feedback loops: recommendations influence behaviour, which becomes future training data. Teams should document data provenance, missingness assumptions, model version, rank and regularisation choices, evaluation populations and known failure modes. Privacy-preserving analysis may require aggregation, access controls, differential privacy or secure computation, depending on the context and applicable law. Best Practices- Centre and scale using training data only; apply the same transformation to validation and deployment data.
- Use QR, Cholesky or SVD solvers rather than explicit matrix inverses.
- Inspect singular values, condition numbers, residuals and sensitivity to perturbation.
- Select rank using both statistical evidence and the downstream purpose.
- Preserve metadata and document how missing values are represented.
- Validate on temporally or operationally appropriate data.
- Assess subgroup performance and possible disparate impact.
- Communicate that latent components are mathematical directions, not necessarily real-world causes.
Contemporary DevelopmentsModern large-scale systems use streaming, randomised and distributed matrix factorisation. Incremental PCA updates a subspace as new observations arrive, while sketching methods compress matrices before decomposition. Tensor decompositions extend factorisation beyond two-way data such as users × items × time. Neural representation learning often uses matrix-factorisation ideas implicitly: embeddings are low-dimensional latent coordinates, and contrastive or reconstruction objectives shape their geometry. Research increasingly focuses on uncertainty in spectral embeddings, robust decomposition under missing-not-at-random data, fairness-aware recommendation and domain adaptation. These developments do not eliminate the need for classical linear algebra; they make correct formulation, conditioning analysis and validation more important. Chapter SummaryDeterminants describe invertibility and volume scaling, but numerical conditioning is generally a better indicator of sensitivity. Eigenvalues and eigenvectors identify invariant directions of square transformations. For symmetric matrices, the spectral theorem gives an orthonormal eigendecomposition, and positive-definite matrices provide well-behaved quadratic forms, covariance structures and optimisation objectives. SVD applies to every real matrix and expresses a transformation through orthogonal input and output directions and nonnegative singular values. Truncated SVD gives the optimal rank-constrained approximation, forming the mathematical basis of PCA, compression and many latent-factor models. PCA is obtained from the SVD of centred data and identifies directions of maximum variance, although its results depend on scaling, outliers and the chosen objective. The Moore–Penrose pseudoinverse provides minimum-norm least-squares solutions for rectangular or rank-deficient systems. SVD exposes small singular values and therefore helps diagnose ill-conditioning and control numerical instability. These tools support recommendation, graph learning, anomaly detection and dimensionality reduction, but responsible practice requires careful treatment of missingness, fairness, privacy, temporal leakage and interpretability. Key TermsDeterminant: A scalar describing invertibility and signed volume scaling of a square linear transformation. Eigenvalue: A scalar λ for which a nonzero vector satisfies Av = λv. Eigenvector: A nonzero invariant-direction vector associated with an eigenvalue. Characteristic polynomial: The polynomial det(A − λI) whose roots are eigenvalues. Eigendecomposition: Representation of a diagonalizable matrix using eigenvectors and eigenvalues. Spectral theorem: The result that every real symmetric matrix has an orthonormal eigenbasis. Positive-definite matrix: A symmetric matrix satisfying xTAx > 0 for every nonzero x. Positive-semidefinite matrix: A symmetric matrix satisfying xTAx ≥ 0 for every x. Quadratic form: An expression of the form xTAx. Singular value: A nonnegative scale factor in the SVD of a matrix. Singular value decomposition: The factorisation A = UΣVT. Rank: The dimension of the column space, equivalently the number of nonzero singular values. Truncated SVD: An SVD retaining only the largest selected singular values. Principal component: A direction in PCA ordered by explained variance. Pseudoinverse: The unique Moore–Penrose generalisation of a matrix inverse. Condition number: A measure of sensitivity, often κ2(A)=σmax/σmin. Latent factor: An unobserved low-dimensional variable used to explain observed relationships. Graph Laplacian: The matrix L=D−A encoding graph connectivity and smoothness. Regularisation: A deliberate constraint or penalty used to reduce overfitting or instability. Review QuestionsShort Answer Questions- What does the determinant of a square matrix indicate about invertibility?
- State the defining equation for an eigenvector and eigenvalue.
- Distinguish positive-definite from positive-semidefinite matrices.
- Why is SVD applicable to rectangular matrices whereas ordinary eigendecomposition is not generally applicable?
- What is the role of small singular values in numerical instability?
Long Answer Questions- Derive the eigendecomposition of a real symmetric matrix and explain the geometric meaning of its eigenvalues and eigenvectors.
- Explain the SVD, including the relationships between singular vectors and eigenvectors of ATA and AAT.
- Develop PCA from a centred data matrix and derive the explained-variance ratio.
- Explain the Moore–Penrose pseudoinverse and its role in overdetermined and underdetermined systems.
- Critically evaluate low-rank matrix factorisation for recommender systems, including missingness, regularisation and fairness.
Analytical / Application Questions- A covariance matrix has eigenvalues 6, 2, 1 and 0. Is it positive definite or positive semidefinite? What proportion of total variance is explained by the first two components?
- A matrix has singular values 10, 4, 0.5 and 0.01. Discuss its conditioning and explain which singular values might be truncated in a stable low-rank model.
- Design a validation and governance plan for a PCA-based industrial anomaly detector whose data arrive continuously and include several protected operational groups.
Multiple Choice Questions with AnswersQuestion 1For a real symmetric matrix, which statement is guaranteed by the spectral theorem? A. It has only positive eigenvalues. B. It has an orthonormal basis of eigenvectors. C. It must be invertible. D. It must be rectangular. Correct Answer: B. It has an orthonormal basis of eigenvectors. Question 2A symmetric matrix with eigenvalues 4, 2 and 0 is: A. Positive definite B. Negative definite C. Positive semidefinite D. Indefinite Correct Answer: C. Positive semidefinite Question 3If the singular values of a matrix are 5, 3 and 1, what is the squared Frobenius norm? A. 9 B. 15 C. 25 D. 35 Correct Answer: D. 35 Question 4Which factorisation is defined for every real matrix, including rectangular matrices? A. SVD B. Cholesky factorisation C. A standard inverse D. A determinant factorisation Correct Answer: A. SVD Question 5In PCA, the variance of component i obtained from an SVD of centred X is: A. σ_i B. σ_i² C. σ_i²/(n−1) D. (n−1)σ_i² Correct Answer: C. σ_i²/(n−1) Question 6What does the Moore–Penrose pseudoinverse provide for an overdetermined system? A. A maximum-norm exact solution in every case B. A minimum-norm least-squares solution C. A guarantee that every equation is satisfied exactly D. A covariance matrix Correct Answer: B. A minimum-norm least-squares solution Question 7Why can forming AᵀA be numerically undesirable? A. It always changes the rank to one. B. It squares the 2-norm condition number. C. It makes all eigenvalues negative. D. It prevents least-squares estimation. Correct Answer: B. It squares the 2-norm condition number. Question 8For a graph Laplacian of an undirected graph, the multiplicity of eigenvalue zero equals the number of: A. Edges B. Vertices C. Connected components D. Nonzero singular values Correct Answer: C. Connected components Question 9If the first three squared singular values sum to 900 and the total sum of squared singular values is 1,000, the first three components explain: A. 9% B. 10% C. 90% D. 900% Correct Answer: C. 90% Question 10In a latent-factor recommender model, the predicted interaction p_uᵀq_i is determined by: A. The determinant of the rating matrix B. The inner product of user and item factor vectors C. The largest covariance eigenvalue only D. The number of missing entries alone Correct Answer: B. The inner product of user and item factor vectors
|