1.1 Centering Multivariate Data and Shifting the Origin to the Mean
Every Principal Component Analysis pipeline begins with an essential coordinate transformation: mean-centering. Before searching for directions of maximum spread or minimum reconstruction error, we must shift the coordinate axes so that the origin sits directly at the empirical center of mass (the sample mean vector ) of the dataset.
Why is centering non-negotiable? Because any vector subspace—whether a 1D line or a -dimensional hyperplane—is mathematically locked to pass through the origin . If the data cloud sits far away from , a line through the origin cannot pass through the middle of the cloud unless it points toward , conflating the average location of the data with its internal directional variance.
In this Article
1. Computing the Sample Mean Vector and Centered Data Matrix
Let be a data matrix whose rows are observations (samples) and whose columns are features (variables). Denote the -th observation as a column vector .
The sample mean vector averages each feature column across all observations:
where is the all-ones column vector. Subtracting from each observation produces the centered vector . In compact matrix form, using the centering matrix :
Zero-Sum Verification Rule: After centering, the sum (and average) of every column of must equal zero exactly: for every feature . This is the quickest arithmetic sanity check when performing PCA by hand.
2. Why Translation Preserves Pairwise Distances and Angles
Does subtracting distort the internal geometry of our dataset? Not at all. Consider the displacement vector between any two observations and after centering:
Because cancels out identically, every pairwise Euclidean distance , every internal angle between pairs of points, and the shape of the cloud's convex hull remain 100% invariant. We have not deformed the cloud; we have merely slid our coordinate crosshairs to its center of gravity.
BEFORE CENTERING (Origin far from cloud) AFTER CENTERING (Origin at centroid)
x2_raw x2
^ * * ^ * *
| * M * (Cloud at M=[10,10]) | * | *
| * * +------*--0--*------> x1
| / | * |
| / <-- Line through (0,0) forced |
+--0---------------------> x1_raw (Line through 0 now slices
(Dominated by vector 0 -> M!) along the cloud's true axis!)
3. The Uncentered Trap: Phantom First Principal Components
Suppose a tight horizontal cloud of points sits around with horizontal spread and vertical spread . Its true direction of variation is purely horizontal ().
However, if you forget to subtract and fit a line through the origin , any horizontal line through misses the cloud by vertical units! To get near the points at , the uncentered algorithm is forced to tilt the line to (), reporting a completely bogus direction that reflects the mean offset rather than the horizontal variance.
4. Step-by-Step Worked Numerical Example
Let us center a 3-observation, 2-feature dataset :
| Observation | Raw Feature 1 () | Raw Feature 2 () | Centered | Centered |
|---|---|---|---|---|
| Column Mean |
Notice how the centered points now lie cleanly on a single line through the origin with direction vector .
5. Active Recall Check and Key Takeaways
Quick Check: Test Your Understanding
Question: Given three 2D observations , , and , compute the mean vector and the centered vector . What is the Euclidean distance between observations 1 and 3 before and after centering?
Answer: The mean vector is . Subtracting from gives (and ). Before centering, the displacement is with distance . After centering, the displacement is with the exact same distance .
- Subspaces pass through : Centering aligns the origin of our vector space with the centroid of the data.
- Rigid translation: Subtracting leaves all pairwise distances, angles, and variances completely unchanged.
- Canonical References: See Scikit-Learn User Guide on Exact PCA and Mean Centering and Wikipedia Reference on the Centering Matrix.
Take a Quiz Based on This Article
Test your understanding with AI-generated questions tailored to this content
Adaptive Learning with SynLearn
Explore this article through guided practice that adapts to your answers