Mercurial > hg > camir-ismir2012
comparison toolboxes/FullBNT-1.0.7/netlab3.3/pca.m @ 0:cc4b1211e677 tip
initial commit to HG from
Changeset:
646 (e263d8a21543) added further path and more save "camirversion.m"
author | Daniel Wolff |
---|---|
date | Fri, 19 Aug 2016 13:07:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cc4b1211e677 |
---|---|
1 function [PCcoeff, PCvec] = pca(data, N) | |
2 %PCA Principal Components Analysis | |
3 % | |
4 % Description | |
5 % PCCOEFF = PCA(DATA) computes the eigenvalues of the covariance | |
6 % matrix of the dataset DATA and returns them as PCCOEFF. These | |
7 % coefficients give the variance of DATA along the corresponding | |
8 % principal components. | |
9 % | |
10 % PCCOEFF = PCA(DATA, N) returns the largest N eigenvalues. | |
11 % | |
12 % [PCCOEFF, PCVEC] = PCA(DATA) returns the principal components as well | |
13 % as the coefficients. This is considerably more computationally | |
14 % demanding than just computing the eigenvalues. | |
15 % | |
16 % See also | |
17 % EIGDEC, GTMINIT, PPCA | |
18 % | |
19 | |
20 % Copyright (c) Ian T Nabney (1996-2001) | |
21 | |
22 if nargin == 1 | |
23 N = size(data, 2); | |
24 end | |
25 | |
26 if nargout == 1 | |
27 evals_only = logical(1); | |
28 else | |
29 evals_only = logical(0); | |
30 end | |
31 | |
32 if N ~= round(N) | N < 1 | N > size(data, 2) | |
33 error('Number of PCs must be integer, >0, < dim'); | |
34 end | |
35 | |
36 % Find the sorted eigenvalues of the data covariance matrix | |
37 if evals_only | |
38 PCcoeff = eigdec(cov(data), N); | |
39 else | |
40 [PCcoeff, PCvec] = eigdec(cov(data), N); | |
41 end | |
42 |