Does anyone know how to implement the Principal component analysis (PCA) on a m-by-n matrix in matlab for normalization?
Does anyone know how to implement the Principal component analysis (PCA) on a m-by-n
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming each column is a sample (that is, you have
nsamples each of dimensionm), and it’s stored in a matrixAyou first have to subtract off the column means:then you want to do an eigenvalue decomposition on
1/size(Amm,2)*Amm*Amm'(you can use1/(size(Amm,2)-1)as a scale factor if you want an interpetation as an unbiased covariance matrix) with:And the columns of
vare going to be your PCA vectors. The entries ofdare going to be your corresponding “variances”.However, if your
mis huge then this is not the best way to go because storingAmm*Amm'is not practical. You want to instead compute:This time
ucontains your PCA vectors. The entries ofsare related to the entries ofdby asqrt.Note: there’s another way to go if
mis huge, i.e. computingeig(1/size(Amm,2)*Amm(notice the switch of transposes as compared to above) and doing a little trickery, but it’s a longer explanation so I won’t get into it.'*Amm);