フィルターのクリア

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

6 ビュー (過去 30 日間)
Andrea Le
Andrea Le 2013 年 11 月 4 日
編集済み: sle 2013 年 11 月 5 日
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 Center および File ExchangeDimensionality 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