[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how can I do Principal Components Analysis with octave?
From: |
Fredrik Lingvall |
Subject: |
Re: how can I do Principal Components Analysis with octave? |
Date: |
Wed, 12 May 2004 10:49:49 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040130 |
Try this:
function [pc,sv,n_sv] = pca(x)
% [pc,sv,n_sv] = pca(x)
%
% Input:
% x - Data stored column-vise .
%
% Output:
% pc - Principal components (eigenvectors of the covariance matrix).
% sv - Singular values.
% n_sv - Normalized singular values.
C = cov(x);
[U,D,pc] = svd(C);
sv = diag(D);
n_sv = 100*sv/sum(sv);
\Fredrik
I believe you would need the programs doing the work. They are called
functions in Octave or Matlab, something like "PCA.m". I would be interested
myself so I checked using Google what MATLAB has:
Here is a list of the functions with a short description of each:
PRINCOMP - principal components from raw data matrix
PCACOV - pca from covariance matrix
PCARES - residuals from pca
BARTTEST - Bartlett's test for dimensionality.
Next I checked for the first two, namely "PRINCOMP" and "PCACOV" in
octave-forge but apparently neither is present. I guess we're out of luck
for the time being unless we have the capability to write the program.
Henry
on 5/11/04 1:04 AM, rino mailing at address@hidden wrote:
I'd like to do Principal Components Analysis with octave
What are the command I ave to write?
How to plot the result?
Thank you in advance for the time you spend to answer me, Mario.
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------