Center the data, compute the covariance matrix; its eigenvectors are the principal components and its eigenvalues are the variance captured along each.
Equivalently, the right singular vectors of the centered data matrix are the principal components, and the squared singular values (divided by n-1) are the variances. SVD is the numerically preferred way to compute PCA.
Explained variance ratio = eigenvalue divided by the sum of all eigenvalues, which guides how many components to keep.
Loading…