STK++ 1.0

STK::Gaussian2BlocksStatModel Class Reference

Compute the the maximum likelihood estimates of a Gaussian tow blocks statistical model. More...

#include <STK_Gaussian2BlocksStatModel.h>

Inheritance diagram for STK::Gaussian2BlocksStatModel:

List of all members.

Public Member Functions

 Gaussian2BlocksStatModel (Matrix const *p_data)
 constructor.
virtual ~Gaussian2BlocksStatModel ()
 destructor.
Integer const & dim () const
 get the dimension of the model.
void setDim (Integer const &dim)
 set the dimension of the model.
bool run (Integer const &dim)
 implementation of the 2 blocks Gaussian statistical model
bool run (Vector const &weights, Integer const &dim)
 implementation of the weighted 2 blocks Gaussian statistical model.

Protected Member Functions

virtual void compCovariance ()
 compute the empirical covariance matrix.
virtual void compWeightedCovariance (Vector const &weights)
 compute the empirical weighted covariance matrix.

Protected Attributes

Integer dim_
 dimension of the 2 block model
Real variance2_
 variance in the second block

Detailed Description

Compute the the maximum likelihood estimates of a Gaussian tow blocks statistical model.

A random vector $ X \in; \mathbb{R}^p $ is a Gaussian two blocks if

\[ X\ \sim\ \mathcal{N}(\mu,\ \Sigma) \]

and

\[ \Sigma = \left( \begin{array}{c@{}c@{}} \begin{array}{|ccc|} \hline & & \\ & \Sigma_{x} & \\ & & \\ \hline \end{array} & \mathbf{0} \\ \mathbf {0} & \begin{array}{|cccc|} \hline \sigma^2 & & & \\ & \ddots & \text{\huge{0}} & \\ & & \ddots & \\ & \text{\huge{0}} & & \sigma^2 \\ \hline \end{array} \\ \end{array} \right) \begin{array}{cc} \left.\begin{array}{c} \\ \\ \\ \end{array} \right\} & d\vspace{1.5ex} \\ \left.\begin{array}{c} \\ \\ \\ \\ \end{array} \right\} & p-d \\ \end{array} \]

where d is a given dimension.

Definition at line 86 of file STK_Gaussian2BlocksStatModel.h.


Constructor & Destructor Documentation

home iovleff Developpement workspace stkpp projects StatModel src STK_Gaussian2BlocksStatModel cpp home iovleff Developpement workspace stkpp projects StatModel src STK_Gaussian2BlocksStatModel cpp STK::Gaussian2BlocksStatModel::Gaussian2BlocksStatModel ( Matrix const *  p_data)

constructor.

The dimension of the model will be initialized to the maximal dimension of the data set (only one block).

Parameters:
p_datapointer on the data set

Definition at line 48 of file STK_Gaussian2BlocksStatModel.cpp.

{ }


STK::Gaussian2BlocksStatModel::~Gaussian2BlocksStatModel ( ) [virtual]

destructor.

Definition at line 55 of file STK_Gaussian2BlocksStatModel.cpp.


Member Function Documentation

Integer const& STK::Gaussian2BlocksStatModel::dim ( ) const [inline]

get the dimension of the model.

Returns:
the dimension of the model

Definition at line 101 of file STK_Gaussian2BlocksStatModel.h.

{ dim_ = dim;}
void STK::Gaussian2BlocksStatModel::setDim ( Integer const &  dim) [inline]

set the dimension of the model.

Parameters:
dimthe dimension of the model

Definition at line 105 of file STK_Gaussian2BlocksStatModel.h.

Referenced by run().

{
bool STK::Gaussian2BlocksStatModel::run ( Integer const &  dim) [inline]

implementation of the 2 blocks Gaussian statistical model

Returns:
true if no error occur and false otherwise.

Definition at line 110 of file STK_Gaussian2BlocksStatModel.h.

References STK::GaussianStatModel::run(), and setDim().

bool STK::Gaussian2BlocksStatModel::run ( Vector const &  weights,
Integer const &  dim 
) [inline]

implementation of the weighted 2 blocks Gaussian statistical model.

Parameters:
weightsthe weights of the samples
dimthe dimension of the first block
Returns:
true if no error occur and false otherwise.

Definition at line 120 of file STK_Gaussian2BlocksStatModel.h.

References STK::GaussianStatModel::run(), and setDim().

    {
      setDim(dim);
      return GaussianStatModel::run(weights);
    }

void STK::Gaussian2BlocksStatModel::compCovariance ( ) [protected, virtual]

compute the empirical covariance matrix.

Reimplemented from STK::GaussianStatModel.

Definition at line 60 of file STK_Gaussian2BlocksStatModel.cpp.

References STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::col(), STK::GaussianStatModel::cov_, STK::GaussianStatModel::mean_, and STK::IRunnerPtr2D< Real, Point, Vector, Matrix >::p_data_.

  {
    cov_(i, i) = Stat::varianceWithFixedMean<Vector>(p_data_->col(i), mean_[i]);
    for (Integer j= first1; j < i; ++j)
    {
      cov_(i, j) = Stat::covarianceWithFixedMean<Vector>(p_data_->col(i), p_data_->col(j), mean_[i], mean_[j]);
      cov_(j, i) = cov_(i,j);
    }
  }
  // get dimensions for the second block
  const Integer first2 = last1+1, last2 = p_data_->lastCol(), size2 = last2 - last1 ;
  if (size2)
  {
    // compute variance of each column
    for (Integer i= first2; i <= last2; ++i)
    { cov_(i, i) = Stat::varianceWithFixedMean<Vector>(p_data_->col(i), mean_[i]);}
    variance2_ = trace(MatrixSquare(cov_, Range(first2, last2)))/(Real)size2;
    // compute variance of each column
    for (Integer i= first2; i <= last2; ++i)
    { cov_(i, i) = variance2_;}
  }
}

/* compute the empirical covariance matrix. */
void STK::Gaussian2BlocksStatModel::compWeightedCovariance ( Vector const &  weights) [protected, virtual]

compute the empirical weighted covariance matrix.

Parameters:
weightsthe weights of the samples

Reimplemented from STK::GaussianStatModel.

Definition at line 91 of file STK_Gaussian2BlocksStatModel.cpp.

References STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::col(), STK::GaussianStatModel::cov_, STK::GaussianStatModel::mean_, and STK::IRunnerPtr2D< Real, Point, Vector, Matrix >::p_data_.

  {
    cov_(i, i) = Stat::varianceWithFixedMean<Vector>(p_data_->col(i), weights, mean_[i]);
    for (Integer j= first1; j < i; ++j)
    {
      cov_(i, j) = 0.;
      cov_(j, i) = 0.;
    }
  }
  // get dimensions for the second block
  const Integer first2 = last1+1, last2 = p_data_->lastCol(), size2 = last2 - last1 ;
  if (size2)
  {
    // compute variance of each column
    for (Integer i= first2; i <= last2; ++i)
    { cov_(i, i) = Stat::varianceWithFixedMean<Vector>(p_data_->col(i), weights, mean_[i]);}
    variance2_ = trace(MatrixSquare(cov_, Range(first2, last2)))/(Real)size2;
    for (Integer i= first2; i <= last2; ++i)
    { cov_(i, i) = variance2_;}
  }
}

} // namespace STK

Member Data Documentation

dimension of the 2 block model

Definition at line 134 of file STK_Gaussian2BlocksStatModel.h.

variance in the second block

Definition at line 136 of file STK_Gaussian2BlocksStatModel.h.


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