Symmetric positive-(semi)definite matrices are fundamental objects in statistics, optimization, and machine learning. Their unique mathematical properties make them indispensable for various statistical applications, from basic covariance estimation to advanced machine learning algorithms.
Author
Yupng L.
Published
November 23, 2025
Introduction
Symmetric positive-(semi)definite matrices are fundamental objects in statistics, optimization, and machine learning. Their unique mathematical properties make them indispensable for various statistical applications, from basic covariance estimation to advanced machine learning algorithms.
Mathematical Foundation
Definition
A symmetric matrix (A symmetric matrix is a square matrix that is equal to its transpose, i.e., A = Aᵀ) \(\mathbf{A} \in \mathbb{R}^{n \times n}\) is:
Positive definite if \(\mathbf{x}^T\mathbf{A}\mathbf{x} > 0\) for all \(\mathbf{x} \neq 0\)
Positive semi-definite if \(\mathbf{x}^T\mathbf{A}\mathbf{x} \geq 0\) for all \(\mathbf{x}\)
Key Properties
Property
Positive definite (PD)
Positive semi-definite (PSD)
Quadratic form
xᵀAx > 0 ∀ x ≠ 0
xᵀAx ≥ 0 ∀ x
Eigenvalues
all > 0
all ≥ 0
Invertibility
always invertible
may be singular (a square matrix that is not invertible, meaning its determinant is zero and its rank is less than its dimension)
Determinant
> 0
≥ 0
Cholesky decomposition
exists (A = LLᵀ)
exists only if singularities are handled (e.g., pivoted Cholesky)
Rank
full rank
can be rank-deficient
Energy interpretation
strictly positive energy
non-negative energy
Convexity
strictly convex quadratic
convex (but not necessarily strict)
Statistical role
full-rank covariance
general covariance (allows perfect collinearity)
positive-definite (PD) ⇔ all eigenvalues > 0
positive-semidefinite (PSD) ⇔ all eigenvalues ≥ 0 (within numeric tolerance)
This is exactly the definition of positive semi-definite.
# Any linear combination of random variables has non-negative varianceset.seed(42)X <- MASS::mvrnorm(1000, mu =c(0, 0), Sigma =matrix(c(1, 0.5, 0.5, 1), 2))Sigma <-cov(X)# Pick any weightsa <-c(3, -2)# Quadratic form = variance of linear combinationquadratic_form <-t(a) %*% Sigma %*% aactual_variance <-var(X %*% a)cat("a'Σa =", round(quadratic_form, 4), "\n")
# PSD but not PD: X3 = X1 + X2 (perfect linear dependence)X1 <-rnorm(100)X2 <-rnorm(100)X3 <- X1 + X2 # Dependent!Sigma_singular <-cov(cbind(X1, X2, X3))eigen(Sigma_singular)$values # One eigenvalue ≈ 0
[1] 3.194783e+00 1.010505e+00 3.108624e-15
3. Principal Component Analysis (PCA)
PCA requires the covariance matrix to be positive semi-definite to ensure that: - Principal components correspond to directions of maximum variance - Eigenvalues represent explained variances: \(\lambda_i \geq 0\)
# PCA via eigen decompositioneig_result <-eigen(cov_sample)# Principal componentsPC1 <- eig_result$vectors[,1]PC2 <- eig_result$vectors[,2]cat("First principal component:", round(PC1, 3))
Symmetric positive-(semi)definite matrices are fundamental to statistics because they:
Ensure mathematical validity of covariance and correlation matrices
Enable efficient computation through specialized algorithms (Cholesky, eigen-decomposition)
Guarantee convexity in optimization problems
Provide geometric interpretation through ellipsoids and quadratic forms
Support advanced methods in machine learning and high-dimensional statistics
Their unique properties make them indispensable tools across the statistical sciences, from basic data analysis to cutting-edge machine learning algorithms. Understanding these matrices is crucial for anyone working in statistics, optimization, or machine learning.
Appendix 1 - Eigenvalues
Eigenvalues tell you how much the matrix stretches space along each eigen-direction; big λ = lots of stretch, tiny λ = almost flat, negative λ = flip + stretch.
Summary: Geometric Meaning of Eigenvalues
Concept
Geometric Interpretation
Eigenvector
Direction that doesn’t rotate under transformation
Eigenvalue
Stretching factor along that direction
λ > 1
Stretch (expand)
0 < λ < 1
Shrink (compress)
λ < 0
Flip (reflect) + scale
λ = 0
Collapse (lose dimension)
Complex λ
Rotation (no fixed direction)
For Symmetric Matrices (Covariance/Hessian)
Eigenvalue Sign
Matrix Type
Geometric Shape
All λ > 0
Positive Definite
Bowl (ellipsoid)
All λ < 0
Negative Definite
Dome (inverted ellipsoid)
Mixed signs
Indefinite
Saddle
Some λ = 0
Semi-definite
Cylinder/flat direction
# =============================================================================# GEOMETRIC UNDERSTANDING OF EIGENVALUES# =============================================================================library(ggplot2)# -----------------------------------------------------------------------------# 1. CORE IDEA: EIGENVECTORS ARE DIRECTIONS THAT DON'T ROTATE# -----------------------------------------------------------------------------# Matrix A transforms vectors. Most vectors change direction.# Eigenvectors ONLY get stretched/shrunk, not rotated.# Eigenvalue = the stretching factorA <-matrix(c(3, 1, 1, 2), nrow =2)eig <-eigen(A)cat("Matrix A:\n"); print(A)
Matrix A:
[,1] [,2]
[1,] 3 1
[2,] 1 2
cat("\nEigenvalues:", round(eig$values, 3))
Eigenvalues: 3.618 1.382
cat("\nλ1 =", round(eig$values[1], 3), "→ stretches by factor", round(eig$values[1], 3))
λ1 = 3.618 → stretches by factor 3.618
cat("\nλ2 =", round(eig$values[2], 3), "→ stretches by factor", round(eig$values[2], 3))
λ2 = 1.382 → stretches by factor 1.382
# -----------------------------------------------------------------------------# 2. VISUALIZE: HOW A MATRIX TRANSFORMS A CIRCLE# -----------------------------------------------------------------------------# A circle becomes an ellipse under linear transformation# Eigenvectors = ellipse axes, Eigenvalues = axis lengths# Unit circle pointstheta <-seq(0, 2*pi, length.out =100)circle <-cbind(cos(theta), sin(theta))# Transform by matrix Aellipse <-t(A %*%t(circle))# Eigenvectors (scaled by eigenvalues for visualization)v1 <- eig$vectors[,1] * eig$values[1]v2 <- eig$vectors[,2] * eig$values[2]df <-data.frame(x_circle = circle[,1], y_circle = circle[,2],x_ellipse = ellipse[,1], y_ellipse = ellipse[,2])ggplot(df) +# Original circlegeom_path(aes(x_circle, y_circle), color ="blue", linewidth =1) +# Transformed ellipsegeom_path(aes(x_ellipse, y_ellipse), color ="red", linewidth =1) +# Eigenvectorsgeom_segment(aes(x =0, y =0, xend = v1[1], yend = v1[2]), arrow =arrow(length =unit(0.3, "cm")), linewidth =1.2) +geom_segment(aes(x =0, y =0, xend = v2[1], yend = v2[2]), arrow =arrow(length =unit(0.3, "cm")), linewidth =1.2) +annotate("text", x = v1[1]*1.15, y = v1[2]*1.15, label =paste0("λ=", round(eig$values[1], 2))) +annotate("text", x = v2[1]*1.15, y = v2[2]*1.15, label =paste0("λ=", round(eig$values[2], 2))) +coord_fixed() +labs(title ="Circle → Ellipse Transformation",subtitle ="Eigenvectors become ellipse axes; Eigenvalues = axis lengths") +theme_minimal()
# -----------------------------------------------------------------------------# 3. THE EIGENVALUE EQUATION GEOMETRICALLY# -----------------------------------------------------------------------------# Av = λv means:# - Apply matrix A to vector v# - Result is just v scaled by λ# - Direction unchanged!v <- eig$vectors[,1] # First eigenvectorAv <- A %*% v # Transform itlambda_v <- eig$values[1] * v # Scale by eigenvaluecat("\n\nEigenvector v:", round(v, 3))
# Simulate dataset.seed(42)data <- MASS::mvrnorm(500, mu =c(0, 0), Sigma = Sigma)# Plot with eigenvectorsdf_data <-data.frame(x = data[,1], y = data[,2])v1 <- eig_sigma$vectors[,1] *sqrt(eig_sigma$values[1]) *2v2 <- eig_sigma$vectors[,2] *sqrt(eig_sigma$values[2]) *2ggplot(df_data, aes(x, y)) +geom_point(alpha =0.3) +geom_segment(aes(x =0, y =0, xend = v1[1], yend = v1[2]), color ="red", linewidth =1.5,arrow =arrow(length =unit(0.3, "cm"))) +geom_segment(aes(x =0, y =0, xend = v2[1], yend = v2[2]), color ="blue", linewidth =1.5,arrow =arrow(length =unit(0.3, "cm"))) +annotate("text", x = v1[1]*1.2, y = v1[2]*1.2, label =paste0("PC1: λ=", round(eig_sigma$values[1], 2)), color ="red") +annotate("text", x = v2[1]*1.2, y = v2[2]*1.2, label =paste0("PC2: λ=", round(eig_sigma$values[2], 2)), color ="blue") +coord_fixed() +labs(title ="PCA: Eigenvalues = Variance Along Principal Axes") +theme_minimal()
# -----------------------------------------------------------------------------# 6. EIGENVALUES AND DEFINITENESS (BACK TO HESSIAN)# -----------------------------------------------------------------------------cat("\n\n=== Connection to Optimization ===\n")