PCA: Find covariance matrix’s eigenvalues: solving a polynomial of degree N

algorithmmathmatrixpca

If I understand correctly, PCA's principle is very simple:

  1. Calculate data vectors' covariance matrix C.
  2. Solve det(Ce***I) = 0, to find matrix **C's eigenvalues e.
  3. Calculate matrix C's eigenvectors (from those eigenvalues).

FIRST: Is this description correct?

SECOND: Any algorithm for machine-solving of the polynomial equation det(Ce***I) = 0 ?
I understand that this is a general math question (finding roots of a polynomial of degree **n
).

THIRD: Are there any simple implementations of PCA in C/C++

Thanks much.

Best Answer

  1. First of all, in order to find eigenvalues there is not need to solve equation you just mentioned. There is such thing as eigendecomposition of a matrix
  2. Second, the covariance matrix is symmetric and positive semi-definite, so eigendecomposition for this matrix is equal to singular value decomposition.
  3. For both mentioned decompositions there is a lot of free and proprietary implementations (the state of the art implemenation is LAPACK).
  4. There is a lot of libraries that contains PCA. If commercial implementations are suitable you can try FinMath from RTMath or NMath from CenterSpace (both for .NET). Otherwise you can try GSL or some other library (there are several questions on StackOverflow that contains more complete list of numerical libraries).
Related Topic