Concise (and correct) version of PCA similarity calculation