42 #include "../../Matrix/Matrix.h"
43 #include "../../Matrix/MatrixTools.h"
53 double tol,
bool verbose) :
61 for (
size_t i = 0; i < nRow; i++)
63 for (
unsigned int j = 0; j < nCol; j++)
66 throw Exception(
"CorrespondenceAnalysis (constructor). Negative value(s) in the input data. This is not allowed !");
73 throw Exception(
"CorrespondenceAnalysis (constructor). All frequencies in the input data are zero...");
78 vector<double> rowWeights(nRow);
79 vector<double> colWeights(nCol);
81 for (
size_t i = 0; i < nRow; i++)
83 for (
unsigned int j = 0; j < nCol; j++)
85 rowWeights[i] += dataTmp(i, j);
86 colWeights[j] += dataTmp(i, j);
90 vector<double> tmpRowWeigths(nRow);
91 vector<double> tmpColWeigths(nCol);
92 for (
size_t i = 0; i < rowWeights.size(); i++)
94 if (rowWeights[i] == 0.)
95 tmpRowWeigths[i] = 0.;
97 tmpRowWeigths[i] = 1. / rowWeights[i];
99 for (
size_t j = 0; j < colWeights.size(); j++)
101 if (colWeights[j] == 0.)
102 tmpColWeigths[j] = 0.;
104 tmpColWeigths[j] = 1. / colWeights[j];
113 setData(weightedData, rowWeights, colWeights, nbAxes, tol, verbose);
CorrespondenceAnalysis(const Matrix< double > &data, unsigned int nbAxes, double tol=0.0000001, bool verbose=true)
Build a new CorrespondenceAnalysis object.
The core class of a multivariate analysis.
void setData(const Matrix< double > &matrix, const std::vector< double > &rowWeights, const std::vector< double > &colWeights, unsigned int nbAxes, double tol=0.0000001, bool verbose=true)
Set the data and perform computations.
Exception base class. Overload exception constructor (to control the exceptions mechanism)....
The matrix template interface.
virtual size_t getNumberOfColumns() const =0
virtual size_t getNumberOfRows() const =0