Example: Covariance and Principal Component Analysis
Calculate the covariance of a data set, and use the eigenvals and eigenvec functions to perform principal component analysis.
1. Define the following matrix D.
Each row of D represents one observation, each column a measured characteristic.
2. Calculate the covariance matrix of the sample.
3. Compute and sort the eigenvalues.
4. Compute the transform matrix.
5. Transform the original data.
6. Calculate the covariance matrix of the transformed data.
The principal components of the data are the diagonal elements of matrix S2.