# Which matrix do we use to calculate principal components in PCA? $X^T X$ or covariance matrix of $X$?

I am reading Principal Component Analysis (PCA) from Wikipedia. Under the details section, it states that the principal components are just eigenvectors of $$X^T X$$ where $$X$$ is the data matrix.

However, this post suggests that principal components are covariance matrix's eigenvectors.

I am confused now. To obtain principal components in PCA, which matrix do we use? $$X^T X$$ or covariance matrix of $$X$$?

• Where's the contradiction? – Rodrigo de Azevedo Apr 1 at 12:28
• No contradiction. I am not sure which matrix to use when I want to calculate principal component. Is it data matrix or its covariance matrix? Do we get the same set of principal components for either matrix? – Idonknow Apr 1 at 12:29
• Isn't $X^T X$ the covariance matrix? – Rodrigo de Azevedo Apr 1 at 12:30
• Opps. I think I need to polish up my knowledge on multivariate covariance matrix. Can you give a reference on showing that $X^T X$ is the covariance matrix of $X$? – Idonknow Apr 1 at 12:33
• Is it? I don't know. To me, this looks like asking about singular vectors and eigenvectors. – Rodrigo de Azevedo Apr 1 at 12:34