35#ifndef STK_STAT_MULTIFACTOR_H
36#define STK_STAT_MULTIFACTOR_H
61 typedef typename Array::Type
Type;
132template <
class Array>
134 , nbLevels_(), levels_(), counts_(), encoder_() {}
136template <
class Array>
138 , asInteger_(p_data_->rows(),p_data_->cols())
140 , nbLevels_(p_data_->cols(), 0)
141 , levels_(p_data_->cols())
142 , counts_(p_data_->cols())
143 , encoder_(p_data_->cols())
144 , decoder_(p_data_->cols())
150template <
class Array>
170template <
class Array>
172 , firstLevel_(
baseIdx), nbLevels_(
f.nbLevels_)
173 , levels_(
f.levels_), counts_(
f.counts_)
174 , encoder_(
f.encoder_)
175 , decoder_(
f.decoder_)
178template <
class Array>
184 asInteger_.resize(p_data_->rows(),p_data_->cols());
186 nbLevels_.resize(p_data_->cols()).setValue(0);
187 for(
int j=encoder_.begin();
j<std::min(encoder_.end(), p_data_->cols().end()); ++
j)
194 levels_.resize(p_data_->cols());
195 counts_.resize(p_data_->cols());
196 encoder_.resize(p_data_->cols());
197 decoder_.resize(p_data_->cols());
201template <
class Array>
210 for (
int j=p_data_->beginCols();
j< p_data_->endCols(); ++
j)
212 for (
int i=p_data_->beginRows();
i< p_data_->endRows(); ++
i)
215 Type idData = p_data_->elt(
i,
j);
216 typename EncodingMap::const_iterator
it = encoder_[
j].find(idData);
217 if (
it != encoder_[
j].end())
219 asInteger_(
i,
j) =
it->second;
220 counts_[
j][
it->second]++;
225 int lev = firstLevel_ + nbLevels_[
j];
226 asInteger_(
i,
j) =
lev;
227 encoder_[
j].insert(std::pair<Type, int>(idData,
lev));
228 decoder_[
j].insert(std::pair<int, Type>(
lev, idData));
229 levels_[
j].push_back(idData);
230 counts_[
j].push_back(1);
238 this->msg_error_ +=
_T(
"Error in MultiFactor::run():\nWhat: ");
239 this->msg_error_ += error.
error();
A Array2DVector is a one dimensional horizontal container.
In this file we implement the final class CArrayPoint.
In this file we implement the final class CArray.
#define STKERROR_NO_ARG(Where, Error)
#define _T(x)
Let x unmodified.
This file include all the other header files of the project Sdk.
Sdk class for all library Exceptions.
virtual const String error() const
Returns a C-style character string describing the general cause of the current error.
Derived & resize(Range const &I, Range const &J)
resize the Array.
Abstract class for all running class based on a data set.
Array const * p_data_
A pointer on the original data set.
Array const * p_data() const
get the data set
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Computation of the MultiFactors of a 2D Container.
CArrayPoint< VectorXi > counts_
Array with the counts of each factor.
CArrayPoint< EncodingMap > Encoder
Decoder decoder_
decoder of the levels
CArrayXXi const & asInteger() const
CArrayPoint< VectorXi > const & counts() const
virtual MultiFactor * clone() const
clone pattern
CArrayPoint< Array2DVector< Type > > levels_
Array with the levels of each variables.
virtual void update()
udpating method in case we set a new data set
CPointXi const & nbLevels() const
Decoder const & decoder() const
virtual ~MultiFactor()
virtual destructor.
IRunnerWithData< Array > Base
Encoder encoder_
encoder of the levels
int firstLevel_
first level number
virtual bool run()
run the estimation of the MultiFactor statistics.
MultiFactor()
Default Constructor.
std::map< Type, int > EncodingMap
CPointXi nbLevels_
Number of levels of each variables.
CArrayXXi asInteger_
Array of the data size with the levels of each variables in an integer format.
Array const * p_data_
A pointer on the original data set.
Encoder const & encoder() const
CArrayPoint< DecodingMap > Decoder
int const & firstLevel() const
CArrayPoint< Array2DVector< Type > > const & levels() const
std::map< int, Type > DecodingMap
void setFirstLevel(int firstLevel)
set the value of the first level
const int baseIdx
base index of the containers created in STK++.
The namespace STK is the main domain space of the Statistical ToolKit project.