This is a classic optimization problem in machine learning. I need to derive Principal Component Analysis (PCA) using Lagrange multipliers, showing that maximizing variance subject to a unit norm constraint leads to finding the eigenvector of the covariance matrix with the largest eigenvalue.
Let me structure this carefully:
- Problem Setup
- Formulate the Optimization Problem
- Apply Lagrange Multipliers
- Solve and Interpret Results
- General Case - Multiple Principal Components
1. Problem Setup
Let's say we have data points x1,x2,…,xn in Rd.
Assume the data is centered (mean is zero). If not, we center it first.
The sample covariance matrix is:
C=n1∑i=1
Or more formally:
C=n1XTX
where X is the n×d data matrix.
2. Variance Maximization Problem
We want to find a direction w (a unit vector) such that when we project the data onto this direction, the variance is maximized.
The projected data is: Xw (each data point gets projected to one dimension).
The variance of the projected data is:
Var=n1(Xw
where C is the covariance matrix.
3. Optimization Problem with Constraint
I need to maximize this variance while keeping w normalized:
maxwwTCw
subject to:
4. Lagrange Multiplier Method
Setting up the Lagrangian with a multiplier λ:
L(w,λ)=wTCw−λ(w
Taking derivatives and setting them to zero yields:
Cw=λw
This is an eigenvalue problem—w must be an eigenvector of the covariance matrix with λ as its eigenvalue.
5. Which Eigenvector?
Since the objective function wTCw=λ when w is normalized, I want the eigenvector corresponding to the largest eigenvalue to maximize variance.
6. Second-Order Conditions
The covariance matrix is positive semi-definite, so all eigenvalues are non-negative and the largest eigenvalue gives the maximum variance.
7. Subsequent Principal Components
The second principal component follows the same logic but with an orthogonality constraint to the first. This yields the eigenvector corresponding to λ2, and the pattern continues—each successive component corresponds to the next-largest eigenvalue in descending order.
Deriving PCA via Lagrange Multipliers
Problem Formulation
Given: Centered data matrix X∈Rn×d with covariance matrix:
C=n
Goal: Find the direction w that maximizes the variance of projected data.
Step 1: Variance of Projected Data
When projecting data onto direction w, the variance is:
Var(w)=n1∥Xw∥
Step 2: Constrained Optimization Problem
Maximize variance subject to unit norm constraint:
\max_{\mathbf{w}} \quad & \mathbf{w}^T\mathbf{C}\mathbf{w}\\
\text{s.t.} \quad & \mathbf{w}^T\mathbf{w} = 1
\end{aligned}$$
---
## Step 3: Lagrangian Formulation
Construct the Lagrangian:
$$\mathcal{L}(\mathbf{w}, \lambda) = \mathbf{w}^T\mathbf{C}\mathbf{w} - \lambda(\mathbf{w}^T\mathbf{w} - 1)$$
---
## Step 4: Optimality Conditions
Take derivatives and set to zero:
$$\frac{\partial \mathcal{L}}{\partial \mathbf{w}} = 2\mathbf{C}\mathbf{w} - 2\lambda\mathbf{w} = 0$$
$$\boxed{\mathbf{C}\mathbf{w} = \lambda\mathbf{w}}$$
**Result:** The optimal $\mathbf{w}$ is an **eigenvector** of $\mathbf{C}$ with eigenvalue $\lambda$.
---
## Step 5: Identifying the Maximum
Multiply the eigenvalue equation by $\mathbf{w}^T$ from the left:
$$\mathbf{w}^T\mathbf{C}\mathbf{w} = \lambda\mathbf{w}^T\mathbf{w} = \lambda \cdot 1$$
**Key insight:** The objective function value equals the eigenvalue!
$$\text{Variance} = \lambda$$
To maximize variance, choose $\mathbf{w}$ corresponding to the **largest eigenvalue** $\lambda_1$:
$$\boxed{\text{PC}_1 = \mathbf{v}_1, \quad \lambda_{1} = \max_i \lambda_i}$$
where $\mathbf{v}_1$ is the eigenvector of $\mathbf{C}$ with largest eigenvalue.
---
## Step 6: Verification via Ordering
Let eigenvalues be ordered: $\lambda_1 \geq \lambda_2 \geq \cdots \geq \lambda_d \geq 0$
For any unit vector $\mathbf{w} = \sum_{i=1}^d c_i\mathbf{v}_i$ where $\sum c_i^2 = 1$:
$$\mathbf{w}^T\mathbf{C}\mathbf{w} = \sum_{i=1}^d c_i^2 \lambda_i \leq \lambda_1 \sum_{i=1}^d c_i^2 = \lambda_1$$
Equality holds when $c_1 = 1$ (i.e., $\mathbf{w} = \mathbf{v}_1$). ✓
---
## Step 7: Subsequent Principal Components
For the $k$-th principal component, add orthogonality constraint:
$$\begin{aligned}
\max_{\mathbf{w}} \quad & \mathbf{w}^T\mathbf{C}\mathbf{w}\\
\text{s.t.} \quad & \mathbf{w}^T\mathbf{w} = 1\\
& \mathbf{w}^T\mathbf{v}_i = 0, \quad i=1,\ldots,k-1
\end{aligned}$$
By identical reasoning, the optimum is the eigenvector with the $k$-th largest eigenvalue:
$$\boxed{\text{PC}_k = \mathbf{v}_k}$$
---
## Summary Table
| Component | Eigenvector | Eigenvalue | Variance Explained |
|-----------|-------------|------------|-------------------|
| PC₁ | $\mathbf{v}_1$ | $\lambda_1$ (largest) | $\frac{\lambda_1}{\sum_i \lambda_i}$ |
| PC₂ | $\mathbf{v}_2$ | $\lambda_2$ | $\frac{\lambda_2}{\sum_i \lambda_i}$ |
| ⋮ | ⋮ | ⋮ | ⋮ |
| PCₖ | $\mathbf{v}_k$ | $\lambda_k$ | $\frac{\lambda_k}{\sum_i \lambda_i}$ |
---
## Geometric Interpretation
- **Covariance matrix eigenvectors** = directions of maximum variance in data
- **Eigenvalues** = amount of variance explained in those directions
- PCA finds orthogonal axes capturing maximum variability sequentially