# Cleve's Cubicle

(Difference between revisions)
 Revision as of 17:58, 17 October 2017 (edit) (New page: Singular Value Decomposition versus Principal Component Analysis SVD meets PCA MATLAB News & Notes, 2006, Cleve’s Corner
“The Wikipedia pages on SVD and PCA are   quite ...)← Previous diff                                                                                                      Current revision (17:27, 12 September 2018) (edit) (undo) (Redirecting to Singular Value Decomposition versus Principal Component Analysis)
(7 intermediate revisions not shown.)
Line 1:                                                                                                                                                                                                                                                                                                                                                                  Line 1:
-                                                                                                                                                                                                                                                                    Singular Value Decomposition versus Principal Component Analysis                             +                                                                                                                                            #REDIRECT [[Singular Value Decomposition versus Principal Component Analysis]]
-                                                                                                                                                                                                                                                                                                                                                                        +
-                                                                                                                                                                                                                                                                    SVD meets PCA                                                                                       +
-                                                                                                                                                                                                                                                                                                                                                                        +
-                                                                                                                                                                                                                                                                    MATLAB News & Notes,                                                                                +
-                                                                                                                                                                                                                                                                    2006,                                                                                               +
-                                                                                                                                                                                                                                                                    Cleve’s Corner                                                                                      +
-                                                                                                                                                                                                                                                                                                                                                                        +
-
-                                                                                                                                                                                                                                                                    quite good and contain a number of useful links,                                                    +
-                                                                                                                                                                                                                                                                    although not to each other.”
+ - + - [itex]-[/itex]https://www.mathworks.com/company/newsletters/articles/professor-svd.html + - + -
+
-                                                                                                                                                                                                                                                                    %relationship of pca to svd                                                                         +
-                                                                                                                                                                                                                                                                    m=3;  n=7;                                                                                          +
-                                                                                                                                                                                                                                                                    A = randn(m,n);                                                                                     +
-                                                                                                                                                                                                                                                                                                                                                                        +
-                                                                                                                                                                                                                                                                    [coef,score,latent] = pca(A);                                                                       +
-                                                                                                                                                                                                                                                                                                                                                                        +
-                                                                                                                                                                                                                                                                    X       = A - mean(A);                                                                              +
-                                                                                                                                                                                                                                                                    [U,S,V] = svd(X,'econ');                                                                            +
-                                                                                                                                                                                                                                                                                                                                                                        +
-                                                                                                                                                                                                                                                                    % U  vs. score                                                                                      +
-                                                                                                                                                                                                                                                                    rho   = rank(X);                                                                                    +
-                                                                                                                                                                                                                                                                    sense = sign(score).*sign(U*S(:,1:rho));  %account for negated left singular vector                 +
-                                                                                                                                                                                                                                                                    sum(sum(abs(score - U*S(:,1:rho).*sense)))                                                          +
-                                                                                                                                                                                                                                                                    % S  vs. latent                                                                                     +
-                                                                                                                                                                                                                                                                    sum(abs(latent - diag(S(:,1:rho)).^2/(m-1)))                                                        +
-                                                                                                                                                                                                                                                                    % V  vs. coef                                                                                       +
-                                                                                                                                                                                                                                                                    sense2 = sign(coef).*sign(V(:,1:rho));    %account for corresponding negated right singular vector  +
-                                                                                                                                                                                                                                                                    sum(sum(abs(coef - V(:,1:rho).*sense2)))                                                            +
-
+

## Current revision

1. REDIRECT Singular Value Decomposition versus Principal Component Analysis