| 1 | #ifndef _PCA_h_ |
| 2 | #define _PCA_h_ |
| 3 | /* PCA.h |
| 4 | * |
| 5 | * Principal Component Analysis |
| 6 | * |
| 7 | * Copyright (C) 1993-2019, 2023 David Weenink |
| 8 | * |
| 9 | * This code is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or (at |
| 12 | * your option) any later version. |
| 13 | * |
| 14 | * This code is distributed in the hope that it will be useful, but |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 21 | */ |
| 22 | |
| 23 | /* |
| 24 | djmw 20020813 GPL header |
| 25 | djmw 20110306 Latest modification. |
| 26 | */ |
| 27 | |
| 28 | |
| 29 | #include "Matrix.h" |
| 30 | #include "TableOfReal.h" |
| 31 | #include "Configuration.h" |
| 32 | #include "Eigen.h" |
| 33 | |
| 34 | #include "PCA_def.h" |
| 35 | |
| 36 | autoPCA PCA_create (integer numberOfComponents, integer dimension); |
| 37 | |
| 38 | void PCA_setNumberOfObservations (PCA me, integer numberOfObservations); |
| 39 | |
| 40 | integer PCA_getNumberOfObservations (PCA me); |
| 41 | |
| 42 | autoPCA TableOfReal_to_PCA_byRows (TableOfReal me); |
| 43 | |
| 44 | autoEigen PCA_to_Eigen (PCA me); |
| 45 | |
| 46 | /* Calculate PCA of M'M */ |
| 47 | |
| 48 | autoPCA Matrix_to_PCA_byRows (Matrix me); |
| 49 | autoPCA Matrix_to_PCA_byColumns (Matrix me); |
| 50 | /* Calculate PCA of M'M */ |
| 51 | |
| 52 | void PCA_getEqualityOfEigenvalues (PCA me, integer from, integer to, int conservative, double *out_prob, double *out_chisq, double *out_df); |
| 53 | /* Morrison, Multivariate statistical methods, page 336 */ |
| 54 | |
| 55 | autoTableOfReal PCA_TableOfReal_to_TableOfReal_projectRows (PCA me, TableOfReal thee, integer numberOfDimensionsToKeep); |
| 56 | autoConfiguration PCA_TableOfReal_to_Configuration (PCA me, TableOfReal thee, integer numberOfDimensions); |
| 57 | |
| 58 | autoTableOfReal PCA_TableOfReal_to_TableOfReal_zscores (PCA me, TableOfReal thee, integer numberOfDimensions); |
| 59 | |
| 60 | double PCA_TableOfReal_getFractionVariance (PCA me, TableOfReal thee, integer from, integer to); |
| 61 | /* Get fraction variance of the table projected in the pca-space. |
| 62 | Shorthand for projecting the Covariance of the TableOfReal on the PCA-space |
| 63 | and querying the projected Covariance for 'fraction variance'. |
| 64 | */ |
| 65 | |
| 66 | autoTableOfReal PCA_Configuration_to_TableOfReal_reconstruct (PCA me, Configuration thee); |
| 67 | /* Reconstruct the original TableOfReal from the PCA and the Configuration */ |
| 68 | |
| 69 | autoTableOfReal PCA_to_TableOfReal_reconstruct1 (PCA me, constVECVU const& coefficients); |
| 70 | |
| 71 | #endif /* _PCA_h_ */ |
| 72 |