Three Worlds, One Idea
Eigen-decomposition is the same operation appearing in three radically different contexts. Each is worth 30 seconds.
PCA — Finding the Big Directions in Data
You have a dataset where each row is a sample and each column is a feature. The covariance matrix tells you how features co-vary. PCA computes its eigenvectors: those eigenvectors are the directions in which your data has the most variation, ranked by eigenvalue size. Project the data onto the top eigenvectors and you've reduced 100-dim data to -dim with minimal information loss.
This is how you visualize 1000-dim embeddings on a 2D scatter plot. PCA picks the 2 directions that preserve as much "shape" of the data as possible.
PageRank — Finding the Important Pages
Google's original ranking algorithm models the web as a graph: each page is a node, each link is an edge. You build a matrix where is the probability of jumping from page to page . The dominant eigenvector of (the eigenvector with the largest eigenvalue) gives you a stationary probability distribution: "if a random surfer clicked links forever, what fraction of time would they spend on each page?" That distribution is the importance score.
The web has billions of pages. Computing the eigenvector exactly is impossible, but iterative algorithms (power iteration) converge to it surprisingly fast. That's PageRank.
Quantum Mechanics — States and Observations
In quantum mechanics, a physical system's state is a vector in a complex vector space. Observable quantities (energy, momentum, position) are operators (matrices). When you measure an observable, you get an eigenvalue of the operator, and the system's state collapses to the corresponding eigenvector. This is the math underneath "the cat is alive AND dead until you look" — superposition is a sum of eigenstates; measurement projects onto one.
SVD — Eigen for Rectangular Matrices
Eigenvalues only exist for square matrices. The Singular Value Decomposition generalizes: it factors any matrix where the singular values in play the role of eigenvalues. SVD powers recommender systems, latent semantic analysis, and image compression.
Track Reward
You walked through the eigen-dungeons and lived. Matrices are transformations. The identity is the do-nothing. The inverse is the undo. Determinants are souls. Eigenvectors are favorite directions. From here on, when someone says "transformer attention" or "covariance projection" or "spectral method," you'll know the chassis underneath.
아직 완전히 와닿진 않지만 eigen을 이렇게 쓰는거구나. pagerank알고리즘은 천재적이다
import numpy as np import matplotlib.pyplot as plt
rng = np.random.default_rng(42)
잠재 구조가 있는 100x5 데이터: 두 숨은 요인이 5개 열을 만든다
n = 100 f1 = rng.standard_normal(n) f2 = rng.standard_normal(n) X = np.column_stack([ f1 + 0.3rng.standard_normal(n), f1 + 0.3rng.standard_normal(n), f2 + 0.3rng.standard_normal(n), f2 + 0.3rng.standard_normal(n), 0.5f1 + 0.5f2 + 0.3*rng.standard_normal(n), ])
1) 열별 표준화 (평균 0, 표준편차 1)
Xs = (X - X.mean(axis=0)) / X.std(axis=0)
2) 공분산 행렬
C = (Xs.T @ Xs) / (n - 1)
3) 대칭행렬 고유분해
vals, vecs = np.linalg.eigh(C)
4) 큰 고유값 순으로 정렬
order = np.argsort(vals)[::-1] vals = vals[order] vecs = vecs[:, order]
5) 처음 두 주성분으로 사영
PC = Xs @ vecs[:, :2]
print("고유값:", np.round(vals, 4)) print("분산 설명 비율:", np.round(vals / vals.sum(), 4)) print("누적:", np.round(np.cumsum(vals / vals.sum()), 4))
6) PC1 vs PC2 산점도
fig, ax = plt.subplots(figsize=(7, 6)) ax.scatter(PC[:, 0], PC[:, 1], s=40, alpha=0.7, edgecolor='white', linewidth=0.5) ax.axhline(0, color='gray', lw=0.5) ax.axvline(0, color='gray', lw=0.5) ax.set_xlabel(f"PC1 ({vals[0]/vals.sum()*100:.1f}%)") ax.set_ylabel(f"PC2 ({vals[1]/vals.sum()*100:.1f}%)") ax.set_title("PCA: first two principal components") ax.set_aspect('equal', adjustable='datalim') plt.tight_layout() plt.savefig('pca_scatter.png', dpi=130)