PCA for a vector such as [100-by-1]

6 次查看(过去 30 天)
Is it reasonable to do a PCA on a vector? I've been using Matlab with this code:
[M,N] = size(A); mn = mean(A);
A = A - repmat(mn,1,N);
B = A'; [u,s,pc] = svd(B);
S_diag = diag(S); V = S_diag .* S_diag;
Aout = PC' * A;
and I got PC is a [100,100] matrix and principal component 1 is Aout(1,1), principal component 2 is Aout(2,1) and so on.
Not sure if this is correct. Please help and Thank you.
  2 个评论
Greg Heath
Greg Heath 2013-11-4
I don't understand your terminology "PCA on a vector". You have performed PCA on a matrix, which is correct.
Or am I missing something?
Andrea Le
Andrea Le 2013-11-4
Hi Greg,
It means I used A as a vector 100-by-1 instead of 100-by-4 matrix for example. The data I care is the variables of 1 observation, not 4 observation for example. The mean I used to translate the vector is the vector's mean. Notice it is mean(A,1). not mean(A,2).
I am trying to figure out if it is reasonable to do a PCA on a vector. I appreciate any suggestion.
Thank you.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2013-11-4
Yup. Consider transposing the vector.
  3 个评论
Walter Roberson
Walter Roberson 2013-11-4
If you have a vector with 100 elements, it can either be a single observation over 100 variables, or it can be 100 observations over a single variable. V compared to transpose(V) .
Consider if you have a single observation over 100 variables. PCA is to find the variable which accounts for the greatest variance. But if there is only a single observation, then the variance for each variable is 0, so the ordering of components would be whatever decision procedure you use to break ties. The easiest such procedure is to order by original index; with a 100-way tie, that would lead to the ordering being 1:100 .
Note: be sure to explicitly code mean(A,1) or mean(A,2) and not mean(A) : mean(A) when A is a row vector is mean(A,2), giving a single mean value, whereas you might be expecting mean of each column of the row vector being returned instead, mean(A,1)
sle
sle 2013-11-5
编辑:sle 2013-11-5
Hello Walter,
Thank you for your comments,
Would you please explain to me one more time what you meant by ordering by original index? Which matrix do you mean by that? I am confused since the component matrix I have is pc(100,100) and pc = pc'; V = V' and S = S'; where every matrix entry of V and S are 0s except at V(1,1) and S(1,1).
For the part of translating data to mean value, do you mean A or A'? Since my input matrix A(100,1) was translated to its mean(A,1) (1 single mean value) then transposed into B(1,100) before doing SVD (because input of PCA is the transpose of input of SVD). Output Aout has the same dimension as A which is 100-by-1
Please correct me if I am doing anything wrong. I very appreciate your help.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dimensionality Reduction and Feature Extraction 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by