Code covered by the BSD License  

Highlights from
Principal Component Analysis

4.66667

4.7 | 7 ratings Rate this file 64 Downloads (last 30 days) File Size: 5.45 KB File ID: #21524

Principal Component Analysis

by Mark Tygert

 

23 Sep 2008 (Updated 06 Feb 2009)

Efficient, accurate principal component analysis

| Watch this File

File Information
Description

The enclosed function PCA implements what is probably the method of choice for computing principal component analyses fairly efficiently, while guaranteeing nearly optimal accuracy. The enclosed function DIFFSNORM provides an efficient, reliable means for checking the accuracies of the low-rank approximations produced by PCA (often the accuracies are slightly better than recently proven bounds guarantee).

Though recently obtained proofs guarantee the accuracy and efficiency of the algorithms implemented in these functions, the enclosed m-files should be considered to be in the beta-testing phase. Although the author has subjected the routines to a battery of tests, he would not be surprised if the functions respond inappropriately to sufficiently bizarre errant input.

Please note that these functions are tailored for the low-rank approximation of large matrices (both dense and sparse).

MATLAB release MATLAB 7.6 (R2008a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (10)
26 Sep 2008 Mark Tygert

Sometimes the QR decomposition in the function PCA takes inordinately long compared to squaring a matrix of the same size. This presumably will not change until the recently introduced communication-avoiding QR decompositions become part of the LAPACK suites.

30 Jan 2009 Christos Boutsidis

Excellent implementation of a fast PCA method...

04 Feb 2009 Henry Nguyen  
05 Feb 2009 Henry Nguyen  
17 Mar 2009 Gabriel Akira Schreiber  
04 Apr 2009 Jon Jackson

Works really well, thanks. Is it possible to get the percentage of the explained variance for each component?

06 May 2009 Wolfgang  
06 May 2009 Wolfgang

But the same question as Jon Jackson. Is it possible to get the explained variances when i just compute (for example) the first three components?

30 Oct 2009 nsmaan Singh

Hello, This is the first time I am trying to use matlab. Since I only have fairly small job to do I am not trying to delve too deep. I have a 5000x5000 matrix like this (just a part...n=till 5000)
 1.0 0.2 0.3 0.1.........n
0.2 1.0 0.1 0.3.........n
0.3 0.1 1.0 0.2..........n
... ... ... ...
n n n n
  
I have been using SpotFire so far for PCA analysis, but this matrix is too huge for its memory, hence trying matlab.
Any help on how i can decompose it into 3 PC's would be greatly appreciated.
Thank you

 

11 May 2011 jose vanaclocha

Hello.
My name is Jose.
I'm student of UPV in spain.
I need help for implement the PCA and PLS algotithms trhogth SVD method.
If someone can help me....
The only one that i have is this:
% PCA MEDIANTE SVD

% ENTRADAS
% A Matriz de datos

% SALIDAS
% u
% S
% V

% MATRIZ DE DATOS
A = [1 2;3 4]

% CALCULAMOS EL TAMAÑO DE LA MATRIZ
[M,N] = size(A);

% CALCULO DE LA MEDIA
mn = mean(A,2);
B = A - repmat(mn,1,N);

% CONSTRUCCION DE LA MATRIZ Y
stdA=std(A)
Y = stdA/ sqrt(N-1);

% APLICAMOS SVD
[u,S,PC] = svd(Y);

% CALCULAMOS LOS OUTPUTS
S = diag(S);
V = S .* S;

Please login to add a comment or rating.
Updates
25 Sep 2008

Improvements to the documentation and slight performance enhancement

25 Sep 2008

Minor bug fix

26 Sep 2008

Performance enhancement

29 Sep 2008

Performance enhancement

29 Sep 2008

Performance enhancement

10 Oct 2008

Enhancement for complex arithmetic

13 Oct 2008

The zip file did not get updated during my last submission

13 Oct 2008

Improved documentation

16 Oct 2008

Updated documentation

03 Nov 2008

Improved memory management

02 Feb 2009

Reduced memory requirements

06 Feb 2009

PCA now will not transpose the matrix being approximated.

Tag Activity for this File
Tag Applied By Date/Time
statistics Mark Tygert 22 Oct 2008 10:20:55
probability Mark Tygert 22 Oct 2008 10:20:55
pca Mark Tygert 22 Oct 2008 10:20:55
svd Mark Tygert 22 Oct 2008 10:20:55
lanczos Mark Tygert 22 Oct 2008 10:20:55
power Mark Tygert 22 Oct 2008 10:20:55
sparse Mark Tygert 22 Oct 2008 10:20:55
principal components analysis Mark Tygert 22 Oct 2008 10:20:55
principal components analysis amine moutaouakil 02 Nov 2008 22:29:08
mathematics Mark Tygert 03 Nov 2008 16:50:58
mathematics Cristina McIntire 07 Nov 2008 12:57:08
probability Cristina McIntire 10 Nov 2008 11:05:33
statistics Cristina McIntire 10 Nov 2008 11:05:35
sparse Henry Nguyen 04 Feb 2009 22:40:05
sparse Anjali Samani 03 Mar 2009 10:01:01
pca Mark 26 May 2009 09:28:55

Contact us at files@mathworks.com