41 #include "../../Matrix/Matrix.h" 42 #include "../../Matrix/MatrixTools.h" 51 double tol,
bool verbose)
throw (
Exception) :
55 size_t nRow = data.getNumberOfRows();
56 size_t nCol = data.getNumberOfColumns();
59 for (
size_t i = 0; i < nRow; i++)
61 for (
unsigned int j = 0; j < nCol; j++)
64 throw Exception(
"CorrespondenceAnalysis (constructor). Negative value(s) in the input data. This is not allowed !");
71 throw Exception(
"CorrespondenceAnalysis (constructor). All frequencies in the input data are zero...");
76 vector<double> rowWeights(nRow);
77 vector<double> colWeights(nCol);
79 for (
size_t i = 0; i < nRow; i++)
81 for (
unsigned int j = 0; j < nCol; j++)
83 rowWeights[i] += dataTmp(i, j);
84 colWeights[j] += dataTmp(i, j);
88 vector<double> tmpRowWeigths(nRow);
89 vector<double> tmpColWeigths(nCol);
90 for (
size_t i = 0; i < rowWeights.size(); i++)
92 if (rowWeights[i] == 0.)
93 tmpRowWeigths[i] = 0.;
95 tmpRowWeigths[i] = 1. / rowWeights[i];
97 for (
size_t j = 0; j < colWeights.size(); j++)
99 if (colWeights[j] == 0.)
100 tmpColWeigths[j] = 0.;
102 tmpColWeigths[j] = 1. / colWeights[j];
111 setData(weightedData, rowWeights, colWeights, nbAxes, tol, verbose);
The matrix template interface.
This class allows to perform a correspondence analysis.
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.