Performs a principal component analysis (PCA).
Perform a PCA by using the original data covariance matrix CovMat. Return the principal components in PC matrix, eigenvalues of the covariance matrix (variances) in vector EigenVec and (optional) the percentage of total variance in vector VarPct. The PC, EigenVec and VarPct dimensions are adjusted automatically.
Uses MtxExpr, Statistics; procedure Example; var Data, PC: Matrix; Variances, ZS: Vector; begin Data.SetIt(2,4,false,[1,3,5,2, 2,5,7,9]); Covariance(data,covMat,false); PCA(covMat,PC,ZS,Variances); //requires cov matrix // Z = [29 , 0, 0 ,0 ] //variance = [100, 0, 0 ,0 ] end;
#include "MtxExpr.hpp" #include "Statistics.hpp" void __fastcall Example() { sMatrix data, PC, covMat; sVector Z,variances; data.SetIt(2,4,false,OPENARRAY(double,(1,3,5,2, 2,5,7,9))); Covariance(data,covMat,false); PCA(covMat,PC,Z,variances); //requires cov matrix // Z = [29 , 0, 0 ,0 ] //variance = [100, 0, 0 ,0 ] }
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
|
What do you think about this topic? Send feedback!
|