37#ifndef STK_GAUSSIANAAMODEL_H
38#define STK_GAUSSIANAAMODEL_H
50template<
class>
class GaussianAAModel;
184 , projectedCovariance_()
185 , residualCovariance_()
186 , residualVariance_(0.)
187 , projectedLnLikelihood_(0.)
188 , residualLnLikelihood_(0.)
196 , projectedCovariance_()
197 , residualCovariance_()
198 , residualVariance_(0.)
199 , projectedLnLikelihood_(0.)
200 , residualLnLikelihood_(0.)
210 Base::setData(workData);
217#ifdef STK_AAMODELS_VERBOSE
218 stk_cout <<
_T(
"GaussianAAModel::computeModelParameters().\n");
221 computeNbFreeParameters();
223 computeResidualCovariance();
225 computeProjectedLnLikelihood();
227 computeResidualLnLikelihood();
229 this->setLnLikelihood(projectedLnLikelihood_ + residualLnLikelihood_);
231#ifdef STK_AAMODELS_VERBOSE
232 stk_cout <<
_T(
"GaussianAAModel::computeModelParameters() done.\n");
241 this->setNbFreeParameter(p_regressor_->nbFreeParameter() + dim() * (dim()+1)/2 + 1);
248#ifdef STK_AAMODELS_VERBOSE
249 stk_cout <<
_T(
"GaussianAAModel::computeProjectedLnLikelihood().\n");
252 Range cols =
Range(p_reduced_->beginCols(), dim());
254 Array reducedData(*p_reduced_, p_reduced_->rows(), cols);
256 ArraySquareX reducedCovariance(projectedCovariance(), cols);
260 projectedLnLikelihood_ = normalP.
lnLikelihood(reducedData);
262#ifdef STK_AAMODELS_VERBOSE
263 stk_cout <<
_T(
"GaussianAAModel::computeProjectedLnLikelihood() done.\n");
264 stk_cout <<
_T(
"projectedLnLikelihood_ = ") << projectedLnLikelihood_ <<
_T(
"\n");
272#ifdef STK_AAMODELS_VERBOSE
273 stk_cout <<
_T(
"GaussianAAModel::computeResidualsLnLikelihood().\n");
276 residualLnLikelihood_ = ( Const::_LNSQRT2PI_ + 0.5*std::log(residualVariance_ ))
277 * (dim() - this->nbVariable()) * this->nbSample();
279 for (
int i=p_residuals_->beginRows(); i<p_residuals_->endRows(); i++)
280 { residualLnLikelihood_ -= p_residuals_->row(i).norm2()/(2.*residualVariance_);}
282#ifdef STK_AAMODELS_VERBOSE
283 stk_cout <<
_T(
"GaussianAAModel::computeResidualsLnLikelihood() done.\n");
284 stk_cout <<
_T(
"residualLnLikelihood_ = ") << residualLnLikelihood_ <<
_T(
"\n");
292#ifdef STK_AAMODELS_DEBUG
296#ifdef STK_AAMODELS_VERBOSE
297 stk_cout <<
_T(
"GaussianAAModel::computeProjectedCovariance().\n");
300#ifdef STK_AAMODELS_VERBOSE
301 stk_cout <<
_T(
"GaussianAAModel::computeProjectedCovariance() done.\n");
308#ifdef STK_AAMODELS_DEBUG
312#ifdef STK_AAMODELS_VERBOSE
313 stk_cout <<
_T(
"in GaussianAAModel::computeResidualCovariance().\n");
316 residualVariance_ = (residualCovariance_.trace())/
Real(this->nbVariable()-dim());
317#ifdef STK_AAMODELS_VERBOSE
318 stk_cout <<
_T(
"GaussianAAModel::computeResidualCovariance() done.\n");
319 stk_cout <<
_T(
"residualVariance_ = ") << residualVariance_ <<
_T(
"\n");
In this file, we define Array2DSquare class.
In this file we define the Interface Base class for all AutoAssociative Models.
In this file we define the class IStatModel.
#define STKRUNTIME_ERROR_NO_ARG(Where, Error)
In this file we define the constant and utilities methods used in the project Model.
In this file we define the multivariate Normal law.
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
Gaussian Auto-Associative models.
void computeModelParameters()
compute the ln-likelihood of the model
ArraySquareX projectedCovariance_
The covariance matrix of the projected data set.
Real const & projectedLnLikelihood() const
void computeNbFreeParameters()
compute the number of free parameter of the model.
Real residualLnLikelihood_
likelihood of the residuals.
IStatModel< GaussianAAModel< Array > > Base
void computeProjectedLnLikelihood()
compute the ln-likelihood of the projected data set The projected data set is assumed Gaussian with a...
virtual ~GaussianAAModel()
virtual destuctor.
void computeResidualCovariance()
compute the covariance matrix of the residuals.
void computeProjectedCovariance()
compute the covariance matrix of the projected data set.
ArraySquareX residualCovariance_
The covariance matrix of the residuals.
void computeResidualLnLikelihood()
compute the ln-likelihood of the projected data set.
ArraySquareX const & projectedCovariance() const
virtual void setWorkData(Array &workData)
Set a new working data set.
GaussianAAModel(Array *p_workData)
Constructor.
Real const & residualVariance() const
Real const & residualLnLikelihood() const
Real projectedLnLikelihood_
likelihood of the projected data set.
ArraySquareX const & residualCovariance() const
Real residualVariance_
The total variance of the residuals.
Array * p_residuals_
Array of the residuals: the data set is shared with p_regressor and set when the regression method is...
Reducer * p_reducer_
pointer on the reeducer.
Array * p_reduced_
Array of the reduced data set : the data set is shared with p_reducer and set when the regression met...
void setWorkData(Array &workData)
Regressor * p_regressor_
pointer on the regression method.
Array const & workData() const
Array * p_predicted_
Array of the predicted data set: the data set is shared with p_regressor and set when the regression ...
Base class for all Statistical Models [Deprecated], have been replaced by IStatModel.
Class for the multivariate Normal distribution.
Real lnLikelihood(Array const &data) const
compute the log likehood of a data set.
Index sub-vector region: Specialization when the size is unknown.
double Real
STK fundamental type of Real values.
hidden::SliceVisitorSelector< Derived, hidden::MeanVisitor, Arrays::by_col_ >::type_result mean(Derived const &A)
If A is a row-vector or a column-vector then the function will return the usual mean value of the vec...
Real covariance(ExprBase< XArray > const &X, ExprBase< YArray > const &Y, bool unbiased=false)
Compute the covariance of the variables X and Y.
The namespace STK is the main domain space of the Statistical ToolKit project.
TRange< UnknownSize > Range