STK++ 0.9.13
STK::GaussianAAModel< Array > Class Template Reference

Gaussian Auto-Associative models. More...

#include <STK_GaussianAAModel.h>

Inheritance diagram for STK::GaussianAAModel< Array >:
Inheritance graph

Public Types

typedef IStatModel< GaussianAAModel< Array > > Base
 
- Public Types inherited from STK::IStatModel< GaussianAAModel< Array > >
typedef hidden::ModelTraits< GaussianAAModel< Array > >::Data Data
 
typedef hidden::ModelTraits< GaussianAAModel< Array > >::ParamHandler ParamHandler
 
typedef Data::Type Type
 Type of the data contained in the container.
 
typedef hidden::Traits< Data >::Row Row
 Type of the row of the data container (a sample)
 

Public Member Functions

 GaussianAAModel (Array *p_workData)
 Constructor.
 
 GaussianAAModel (Array &workData)
 Constructor.
 
virtual ~GaussianAAModel ()
 virtual destuctor.
 
Real constprojectedLnLikelihood () const
 
Real constresidualLnLikelihood () const
 
ArraySquareX constprojectedCovariance () const
 
ArraySquareX constresidualCovariance () const
 
Real constresidualVariance () const
 
virtual void setWorkData (Array &workData)
 Set a new working data set.
 
void computeProjectedCovariance ()
 compute the covariance matrix of the projected data set.
 
void computeModelParameters ()
 compute the ln-likelihood of the model
 
- Public Member Functions inherited from STK::IAAModel< Array >
 ~IAAModel ()
 destructor.
 
Array constworkData () const
 
Reducer *constp_reducer () const
 
Regressor *constp_regressor () const
 
Array *constp_reduced () const
 
Array *constp_predicted () const
 
Array *constp_residuals () const
 
int dim () const
 
bool isCentered () const
 
bool isStandardized () const
 
PointX constmean () const
 
PointX conststd () const
 
void setDimension (int const &dim)
 
void setWorkData (Array &workData)
 
void setReducer (Reducer *p_reducer)
 
void setRegressor (Regressor *p_regressor)
 
void freeReducer ()
 delete the reducer set to this model by the method setReducer.
 
void freeRegressor ()
 delete the regressor set to this model by the method setRegressor.
 
void center ()
 center the data set workData_.
 
void center (VectorX const &weights)
 weighted centering of the data set.
 
void standardize ()
 standardize the data set.
 
void standardize (VectorX const &weights)
 weighted standardization the data set.
 
void reductionStep ()
 compute the reduction of the data set and store the result in the p_reduced_ container.
 
void reductionStep (VectorX const &weights)
 compute the weighted dimension reduction of the data set and store the result in the p_reduced_ container.
 
void regressionStep ()
 compute the regression of the original data set and set the results in p_predicted and p_residuals.
 
void regressionStep (VectorX const &weights)
 compute the weighted regression of the original data set using the reduced data set as predictor and set the results in p_predicted and p_residuals.
 
void uncenterResults ()
 uncenter the predicted data set.
 
void unstandardizeResults ()
 unstandardize the predicted data set and the residuals.
 
- Public Member Functions inherited from STK::IStatModel< GaussianAAModel< Array > >
 ~IStatModel ()
 destructor
 
Data const *const p_dataij () const
 
void setData (Data const &data)
 Set the data set of the model.
 
void setData (Data const *p_data)
 Set the data set of the model.
 
- Public Member Functions inherited from STK::IStatModelBase
int nbSample () const
 
Real lnNbSample () const
 
int nbVariable () const
 
Real lnLikelihood () const
 
Real likelihood () const
 
int nbFreeParameter () const
 
Real computeBIC () const
 
Real computeAIC () const
 
Real computeML () const
 

Protected Member Functions

void computeNbFreeParameters ()
 compute the number of free parameter of the model.
 
void computeResidualCovariance ()
 compute the covariance matrix of the residuals.
 
void computeProjectedLnLikelihood ()
 compute the ln-likelihood of the projected data set The projected data set is assumed Gaussian with an arbitrary covariance Array.
 
void computeResidualLnLikelihood ()
 compute the ln-likelihood of the projected data set.
 
- Protected Member Functions inherited from STK::IAAModel< Array >
 IAAModel (Array *p_workData)
 Constructor.
 
 IAAModel (Array &workData)
 Constructor.
 
- Protected Member Functions inherited from STK::IStatModel< GaussianAAModel< Array > >
 IStatModel (Data const &data)
 Constructor with data set.
 
 IStatModel (Data const *p_data)
 Constructor with a ptr on the data set.
 
- Protected Member Functions inherited from STK::IStatModelBase
 IStatModelBase ()
 Default constructor.
 
 IStatModelBase (int nbSample)
 Constructor with specified dimension.
 
 IStatModelBase (int nbSample, int nbVariable)
 Constructor with specified dimension.
 
 IStatModelBase (IStatModelBase const &model)
 Copy constructor.
 
 ~IStatModelBase ()
 destructor
 
void setNbFreeParameter (int const &nbFreeParameter)
 set the number of free parameters of the model
 
void setNbSample (int const &nbSample)
 set the number of samples of the model
 
void setNbVariable (int const &nbVariable)
 set the number of variables of the model
 
void setLnLikelihood (Real const &lnLikelihood)
 set the log-likelihood of the model
 
void initialize (int nbSample, int nbVariable)
 set the dimensions of the parameters of the model
 

Private Attributes

ArraySquareX projectedCovariance_
 The covariance matrix of the projected data set.
 
ArraySquareX residualCovariance_
 The covariance matrix of the residuals.
 
Real residualVariance_
 The total variance of the residuals.
 
Real projectedLnLikelihood_
 likelihood of the projected data set.
 
Real residualLnLikelihood_
 likelihood of the residuals.
 

Additional Inherited Members

- Protected Attributes inherited from STK::IAAModel< Array >
Regressorp_regressor_
 pointer on the regression method.
 
Reducerp_reducer_
 pointer on the reeducer.
 
Array * p_workData_
 Array of the local data set.
 
Array * p_reduced_
 Array of the reduced data set : the data set is shared with p_reducer and set when the regression method is call.
 
Array * p_predicted_
 Array of the predicted data set: the data set is shared with p_regressor and set when the regression method is call.
 
Array * p_residuals_
 Array of the residuals: the data set is shared with p_regressor and set when the regression method is call.
 
- Protected Attributes inherited from STK::IStatModel< GaussianAAModel< Array > >
Data constp_dataij_
 A pointer on the original data set.
 

Detailed Description

template<class Array>
class STK::GaussianAAModel< Array >

Gaussian Auto-Associative models.

A Gaussian Auto-Associative model is a p-dimensional vector $\mathbf{y}$ with projection function $\mathbf{P}$ and regression function $\mathbf{R}$, if it can be written

\[
  \mathbf{y} = \mathbf{Q}
  \left(
  \begin{pmatrix}
    x_1 \\ \vdots \\
    x_d \\
    \tilde{r}_{d+1}(\mathbf{x}) \\ \vdots \\
    \tilde{r}_p(\mathbf{x})
  \end{pmatrix}
   + \tilde{\varepsilon}
  \right)
  = R(\mathbf{x})+ \varepsilon,
\]

where the $\tilde{r}_j(\mathbf{x})$, $ d+1 \leq j \leq p$, are arbitrary real functions from $\mathbb{R}^d$ to $\mathbb{R}$.

The vector $\mathbf{x}$ is a $d$-dimensional Gaussian random vector:

\[
  \mathbf{x} \sim \mathcal{N}(\mu_x, \Sigma_x)
\]

with covariance matrix $\Sigma_x = \mathrm{Diag}(\sigma_1^2, \ldots, \sigma_d^2)$.

The Gaussian noise $\tilde{\varepsilon}$ is centered with the following covariance matrix $\Sigma_\varepsilon =
\mathrm{diag}(0,\ldots,0,\sigma^2,\ldots,\sigma^2)$.

The GaussianModel class is a factory class which compute the covariance matrix of x, the residual covariance and the number of free parameters of the model. It can be sub-classed or used by any class.

Definition at line 101 of file STK_GaussianAAModel.h.

Member Typedef Documentation

◆ Base

template<class Array >
typedef IStatModel< GaussianAAModel<Array> > STK::GaussianAAModel< Array >::Base

Definition at line 105 of file STK_GaussianAAModel.h.

Constructor & Destructor Documentation

◆ GaussianAAModel() [1/2]

template<class Array >
STK::GaussianAAModel< Array >::GaussianAAModel ( Array *  p_workData)

Constructor.

Parameters
p_workDataa pointer on the data set to process

Definition at line 181 of file STK_GaussianAAModel.h.

182 : IAAModel<Array>(p_workData)
183 , Base(p_workData)
189{ }
ArraySquareX projectedCovariance_
The covariance matrix of the projected data set.
Real residualLnLikelihood_
likelihood of the residuals.
IStatModel< GaussianAAModel< Array > > Base
ArraySquareX residualCovariance_
The covariance matrix of the residuals.
Real projectedLnLikelihood_
likelihood of the projected data set.
Real residualVariance_
The total variance of the residuals.

◆ GaussianAAModel() [2/2]

template<class Array >
STK::GaussianAAModel< Array >::GaussianAAModel ( Array &  workData)

Constructor.

Parameters
workDataa reference on the data set to process

Definition at line 193 of file STK_GaussianAAModel.h.

194 : IAAModel<Array>(workData)
195 , Base(workData)
201{ }
Array const & workData() const

◆ ~GaussianAAModel()

template<class Array >
virtual STK::GaussianAAModel< Array >::~GaussianAAModel ( )
inlinevirtual

virtual destuctor.

Definition at line 121 of file STK_GaussianAAModel.h.

121{}

Member Function Documentation

◆ computeModelParameters()

template<class Array >
void STK::GaussianAAModel< Array >::computeModelParameters ( )

compute the ln-likelihood of the model

Definition at line 215 of file STK_GaussianAAModel.h.

216{
217#ifdef STK_AAMODELS_VERBOSE
218 stk_cout << _T("GaussianAAModel::computeModelParameters().\n");
219#endif
220 // compute the number of free parameters
222 // compute the covariance matrix of the residual and the residual variance
224 // compute projected lnLikelihood
226 // compute projected lnLikelihood
228 // compute complete nLikelihood
230
231#ifdef STK_AAMODELS_VERBOSE
232 stk_cout << _T("GaussianAAModel::computeModelParameters() done.\n");
233#endif
234}
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
void computeNbFreeParameters()
compute the number of free parameter of the model.
void computeProjectedLnLikelihood()
compute the ln-likelihood of the projected data set The projected data set is assumed Gaussian with a...
void computeResidualCovariance()
compute the covariance matrix of the residuals.
void computeResidualLnLikelihood()
compute the ln-likelihood of the projected data set.
void setLnLikelihood(Real const &lnLikelihood)
set the log-likelihood of the model

References _T, and stk_cout.

◆ computeNbFreeParameters()

template<class Array >
void STK::GaussianAAModel< Array >::computeNbFreeParameters ( )
protected

compute the number of free parameter of the model.

It is given by the number of parameter of the regression function, the number of variance and covariance of the projected data set (d * (d+1))/2 and the variance of the residuals.

Definition at line 239 of file STK_GaussianAAModel.h.

240{
241 this->setNbFreeParameter(p_regressor_->nbFreeParameter() + dim() * (dim()+1)/2 + 1);
242}
int dim() const
Regressor * p_regressor_
pointer on the regression method.
int nbFreeParameter() const
void setNbFreeParameter(int const &nbFreeParameter)
set the number of free parameters of the model

◆ computeProjectedCovariance()

template<class Array >
void STK::GaussianAAModel< Array >::computeProjectedCovariance ( )

compute the covariance matrix of the projected data set.

This method is set public as the projected covariance can be computed only the first time the data set is projected.

Definition at line 290 of file STK_GaussianAAModel.h.

291{
292#ifdef STK_AAMODELS_DEBUG
293 if (!p_reduced_)
295#endif
296#ifdef STK_AAMODELS_VERBOSE
297 stk_cout << _T("GaussianAAModel::computeProjectedCovariance().\n");
298#endif
300#ifdef STK_AAMODELS_VERBOSE
301 stk_cout << _T("GaussianAAModel::computeProjectedCovariance() done.\n");
302#endif
303}
#define STKRUNTIME_ERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:138
void computeProjectedCovariance()
compute the covariance matrix of the projected data set.
Array * p_reduced_
Array of the reduced data set : the data set is shared with p_reducer and set when the regression met...
Real covariance(ExprBase< XArray > const &X, ExprBase< YArray > const &Y, bool unbiased=false)
Compute the covariance of the variables X and Y.

References _T, STK::GaussianAAModel< Array >::computeProjectedCovariance(), STK::Stat::covariance(), stk_cout, and STKRUNTIME_ERROR_NO_ARG.

Referenced by STK::GaussianAAModel< Array >::computeProjectedCovariance().

◆ computeProjectedLnLikelihood()

template<class Array >
void STK::GaussianAAModel< Array >::computeProjectedLnLikelihood ( )
protected

compute the ln-likelihood of the projected data set The projected data set is assumed Gaussian with an arbitrary covariance Array.

Definition at line 246 of file STK_GaussianAAModel.h.

247{
248#ifdef STK_AAMODELS_VERBOSE
249 stk_cout << _T("GaussianAAModel::computeProjectedLnLikelihood().\n");
250#endif
251 // range of the column to use
252 Range cols = Range(p_reduced_->beginCols(), dim());
253 // create a reference with the first columns of the reduced data
254 Array reducedData(*p_reduced_, p_reduced_->rows(), cols);
255 // create a reference with the first columns of the reduced data
256 ArraySquareX reducedCovariance(projectedCovariance(), cols);
257 // compute first part of the ln-likelihood
258 PointX mean(cols, 0.);
259 MultiLaw::Normal<PointX> normalP(mean, reducedCovariance);
260 projectedLnLikelihood_ = normalP.lnLikelihood(reducedData);
261
262#ifdef STK_AAMODELS_VERBOSE
263 stk_cout << _T("GaussianAAModel::computeProjectedLnLikelihood() done.\n");
264 stk_cout << _T("projectedLnLikelihood_ = ") << projectedLnLikelihood_ << _T("\n");
265#endif
266}
ArraySquareX const & projectedCovariance() const
PointX const & mean() const
Array2DPoint< Real > PointX
final class for a Real horizontal container.
Array2DSquare< Real > ArraySquareX
TRange< UnknownSize > Range
Definition STK_Range.h:59

References _T, STK::MultiLaw::Normal< RowVector >::lnLikelihood(), STK::mean(), and stk_cout.

◆ computeResidualCovariance()

template<class Array >
void STK::GaussianAAModel< Array >::computeResidualCovariance ( )
protected

compute the covariance matrix of the residuals.

Definition at line 306 of file STK_GaussianAAModel.h.

307{
308#ifdef STK_AAMODELS_DEBUG
309 if (!p_residuals_)
311#endif
312#ifdef STK_AAMODELS_VERBOSE
313 stk_cout << _T("in GaussianAAModel::computeResidualCovariance().\n");
314#endif
317#ifdef STK_AAMODELS_VERBOSE
318 stk_cout << _T("GaussianAAModel::computeResidualCovariance() done.\n");
319 stk_cout << _T("residualVariance_ = ") << residualVariance_ << _T("\n");
320#endif
321}
Array * p_residuals_
Array of the residuals: the data set is shared with p_regressor and set when the regression method is...
double Real
STK fundamental type of Real values.

References _T, STK::GaussianAAModel< Array >::computeResidualCovariance(), STK::Stat::covariance(), stk_cout, and STKRUNTIME_ERROR_NO_ARG.

Referenced by STK::GaussianAAModel< Array >::computeResidualCovariance().

◆ computeResidualLnLikelihood()

template<class Array >
void STK::GaussianAAModel< Array >::computeResidualLnLikelihood ( )
protected

compute the ln-likelihood of the projected data set.

The residuals are assumed orthogonal to the the projected data set with a single residual variance.

Definition at line 270 of file STK_GaussianAAModel.h.

271{
272#ifdef STK_AAMODELS_VERBOSE
273 stk_cout << _T("GaussianAAModel::computeResidualsLnLikelihood().\n");
274#endif
275 // compute constant part and determinant part of the log-likelihood
276 residualLnLikelihood_ = ( Const::_LNSQRT2PI_ + 0.5*std::log(residualVariance_ ))
277 * (dim() - this->nbVariable()) * this->nbSample();
278 // compute second part of the log-likelihood
279 for (int i=p_residuals_->beginRows(); i<p_residuals_->endRows(); i++)
280 { residualLnLikelihood_ -= p_residuals_->row(i).norm2()/(2.*residualVariance_);}
281
282#ifdef STK_AAMODELS_VERBOSE
283 stk_cout << _T("GaussianAAModel::computeResidualsLnLikelihood() done.\n");
284 stk_cout << _T("residualLnLikelihood_ = ") << residualLnLikelihood_ << _T("\n");
285#endif
286}

References _T, and stk_cout.

◆ projectedCovariance()

template<class Array >
ArraySquareX const & STK::GaussianAAModel< Array >::projectedCovariance ( ) const
inline
Returns
the covariance matrix of the projected the data set

Definition at line 127 of file STK_GaussianAAModel.h.

127{ return projectedCovariance_;}

References STK::GaussianAAModel< Array >::projectedCovariance_.

◆ projectedLnLikelihood()

template<class Array >
Real const & STK::GaussianAAModel< Array >::projectedLnLikelihood ( ) const
inline
Returns
the ln-likelihood of the projected data set

Definition at line 123 of file STK_GaussianAAModel.h.

123{ return projectedLnLikelihood_;}

References STK::GaussianAAModel< Array >::projectedLnLikelihood_.

◆ residualCovariance()

template<class Array >
ArraySquareX const & STK::GaussianAAModel< Array >::residualCovariance ( ) const
inline
Returns
the covairance matrix of the residuals

Definition at line 129 of file STK_GaussianAAModel.h.

129{ return residualCovariance_;}

References STK::GaussianAAModel< Array >::residualCovariance_.

◆ residualLnLikelihood()

template<class Array >
Real const & STK::GaussianAAModel< Array >::residualLnLikelihood ( ) const
inline
Returns
the ln-likelihood of the residuals

Definition at line 125 of file STK_GaussianAAModel.h.

125{ return residualLnLikelihood_;}

References STK::GaussianAAModel< Array >::residualLnLikelihood_.

◆ residualVariance()

template<class Array >
Real const & STK::GaussianAAModel< Array >::residualVariance ( ) const
inline
Returns
the variance of the residuals

Definition at line 131 of file STK_GaussianAAModel.h.

131{ return residualVariance_;}

References STK::GaussianAAModel< Array >::residualVariance_.

◆ setWorkData()

template<class Array >
void STK::GaussianAAModel< Array >::setWorkData ( Array &  workData)
virtual

Set a new working data set.

Parameters
workDatathe working data set to use

Definition at line 205 of file STK_GaussianAAModel.h.

206{
207 // update data set and flags for the IAAModel part
209 // set dimensions to new size for the IStatModel part
211}
void setWorkData(Array &workData)
void setData(Data const &data)
Set the data set of the model.

References STK::IAAModel< Array >::setWorkData().

Referenced by STK::LinearAAModel< Array >::LinearAAModel(), and STK::LinearAAModel< Array >::LinearAAModel().

Member Data Documentation

◆ projectedCovariance_

template<class Array >
ArraySquareX STK::GaussianAAModel< Array >::projectedCovariance_
private

The covariance matrix of the projected data set.

Definition at line 166 of file STK_GaussianAAModel.h.

Referenced by STK::GaussianAAModel< Array >::projectedCovariance().

◆ projectedLnLikelihood_

template<class Array >
Real STK::GaussianAAModel< Array >::projectedLnLikelihood_
private

likelihood of the projected data set.

Definition at line 172 of file STK_GaussianAAModel.h.

Referenced by STK::GaussianAAModel< Array >::projectedLnLikelihood().

◆ residualCovariance_

template<class Array >
ArraySquareX STK::GaussianAAModel< Array >::residualCovariance_
private

The covariance matrix of the residuals.

Definition at line 168 of file STK_GaussianAAModel.h.

Referenced by STK::GaussianAAModel< Array >::residualCovariance().

◆ residualLnLikelihood_

template<class Array >
Real STK::GaussianAAModel< Array >::residualLnLikelihood_
private

likelihood of the residuals.

Definition at line 174 of file STK_GaussianAAModel.h.

Referenced by STK::GaussianAAModel< Array >::residualLnLikelihood().

◆ residualVariance_

template<class Array >
Real STK::GaussianAAModel< Array >::residualVariance_
private

The total variance of the residuals.

Definition at line 170 of file STK_GaussianAAModel.h.

Referenced by STK::GaussianAAModel< Array >::residualVariance().


The documentation for this class was generated from the following file: