Mean variance and covariance matrices
Centering subtracts each feature mean. The sample covariance matrix XᵀX/(n−1) records individual variance on its diagonal and shared variation off its diagonal.
What you will learn
- Compute means and center features
- Compute sample covariance and identify variance
- Interpret covariance rank
Work through one complete example
- Observations (1,2,3),(2,4,6),(3,6,9) have mean (2,4,6).
- Centered rows are (−1,−2,−3),(0,0,0),(1,2,3). Their XᵀX is [[2,4,6],[4,8,12],[6,12,18]].
- Divide by n−1=2 to get covariance [[1,2,3],[2,4,6],[3,6,9]].
- The second and third features are multiples of the first, so the 3×3 covariance has rank 1. Zero covariance generally does not imply independence.
Objective 1: Compute means and center features
- Find the mean and first centered observation.
- Mean (2,4,6); first centered row (−1,−2,−3).
Objective 2: Compute sample covariance and identify variance
- What divisor is used for n=3, and what are Σ₁₁,Σ₁₂?
- Divide by 2. Σ₁₁=1 is variance; Σ₁₂=2 is cross-covariance.
Objective 3: Interpret covariance rank
- Why does the 3×3 covariance have rank 1?
- Columns 2 and 3 are 2 and 3 times column 1, leaving one independent direction.
A common mistake
State the assumptions before using the formula.
Review first
Continue learning
Mean variance and covariance matrices
Interactive diagnosis and practice load in the learning app. You can read these lesson notes without JavaScript.