Vespucci  1.0.0
principalcomponentsdata.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright (C) 2015 Wright State University - All Rights Reserved
3  Daniel P. Foose - Author
4 
5  This file is part of Vespucci.
6 
7  Vespucci is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  Vespucci is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Vespucci. If not, see <http://www.gnu.org/licenses/>.
19 *******************************************************************************/
21 
28  AnalysisResults(name, "PCA Results")
29 {
30 
31 }
32 
37 void PrincipalComponentsData::Apply(const mat &spectra)
38 {
39  mat coeff, score, percent_variance;
40  vec latent, tsquared;
41  princomp(coeff, score, latent, tsquared, spectra.t());
42  double eigenvalue_sum = sum(latent);
43  percent_variance = latent / eigenvalue_sum;
44  percent_variance /= 0.01;
45  vec cumulative = cumsum(percent_variance);
46  percent_variance = join_horiz(percent_variance, cumulative);
47 
48  AddMatrix("Scores", score);
49  AddMatrix("Loadings", coeff);
50  AddMatrix("Eigenvalues", latent);
51  AddMatrix("Percent Variance", percent_variance);
52  AddMatrix("Hotelling t²", tsquared);
53 }
void Apply(const mat &spectra)
PrincipalComponentsData::Apply.
void AddMatrix(const QString &key, const mat &value, QStringList column_headings=QStringList())
The AnalysisResults class A container for a mat object that allows a mat to be copied to a heap-alloc...
PrincipalComponentsData(QString name)
PrincipalComponentsData::PrincipalComponentsData.