STK++ 0.9.13
STK::ModelParameters< Clust::Categorical_pk_ > Struct Reference

Structure encapsulating the parameters of a Categorical_pk model. More...

#include <STK_CategoricalParameters.h>

Public Member Functions

 ModelParameters (int nbCluster)
 default constructor
 
 ModelParameters (ModelParameters const &param)
 copy constructor.
 
 ~ModelParameters ()
 destructor
 
ModelParametersoperator= (ModelParameters const &param)
 copy operator.
 
Real constproba (int k, int j, int l) const
 
CVectorX proba (int k, int j) const
 
void resize (Range const &rangeModalities, Range const &rangeCols)
 resize the set of parameter
 
void updateStatistics ()
 update statistics of the parameters.
 
void setStatistics ()
 set and release the computed statistics
 
void releaseStatistics ()
 Set the computed statistics.
 
template<class Array >
void setParameters (ExprBase< Array > const &params)
 Set the parameters of the mixture model.
 

Public Attributes

Array1D< CVectorXproba_
 array of size nbCluster with the probabilities of the variables
 
Array1D< Stat::Online< CVectorX, Real > > stat_proba_
 array of size nbCluster with the statistics of the probabilities
 

Detailed Description

Structure encapsulating the parameters of a Categorical_pk model.

Definition at line 118 of file STK_CategoricalParameters.h.

Constructor & Destructor Documentation

◆ ModelParameters() [1/2]

STK::ModelParameters< Clust::Categorical_pk_ >::ModelParameters ( int  nbCluster)

default constructor

Parameters
nbClusterthe number of class of the mixture

Definition at line 101 of file STK_CategoricalParameters.cpp.

102 : proba_(nbCluster), stat_proba_(nbCluster) {}
Array1D< Stat::Online< CVectorX, Real > > stat_proba_
array of size nbCluster with the statistics of the probabilities
Array1D< CVectorX > proba_
array of size nbCluster with the probabilities of the variables

◆ ModelParameters() [2/2]

copy constructor.

Parameters
paramthe parameters to copy.

Definition at line 106 of file STK_CategoricalParameters.cpp.

107 : proba_(param.proba_), stat_proba_(param.stat_proba_)
108{}

◆ ~ModelParameters()

destructor

Definition at line 110 of file STK_CategoricalParameters.cpp.

110{}

Member Function Documentation

◆ operator=()

copy operator.

Parameters
paramthe parameters to copy.

Definition at line 114 of file STK_CategoricalParameters.cpp.

115{
116 proba_ = param.proba_;
117 stat_proba_ = param.stat_proba_;
118 return *this;
119}

◆ proba() [1/2]

CVectorX STK::ModelParameters< Clust::Categorical_pk_ >::proba ( int  k,
int  j 
) const
inline
Returns
the probabilities of the kth cluster for the jth variable

Definition at line 144 of file STK_CategoricalParameters.h.

144{ return proba_[k];}

◆ proba() [2/2]

Real const & STK::ModelParameters< Clust::Categorical_pk_ >::proba ( int  k,
int  j,
int  l 
) const
inline
Returns
the probability of the kth cluster, jth variable, lth modality

Definition at line 142 of file STK_CategoricalParameters.h.

142{ return proba_[k][l];}

◆ releaseStatistics()

Set the computed statistics.

Definition at line 146 of file STK_CategoricalParameters.cpp.

147{
148 for(int k=stat_proba_.begin(); k<stat_proba_.end(); ++k)
149 { stat_proba_[k].release();}
150}

◆ resize()

void STK::ModelParameters< Clust::Categorical_pk_ >::resize ( Range const rangeModalities,
Range const rangeCols 
)

resize the set of parameter

Parameters
rangeModalitiesrange of the modalities
rangeColsrange of the variables (not used)

Definition at line 122 of file STK_CategoricalParameters.cpp.

123{
124 for (int k = proba_.begin(); k< proba_.end(); ++k)
125 {
126 proba_[k].resize(rangeModalities) = 1./rangeModalities.size();
127 stat_proba_[k].resize(rangeModalities);
128 }
129}

◆ setParameters()

template<class Array >
void STK::ModelParameters< Clust::Categorical_pk_ >::setParameters ( ExprBase< Array > const params)
inline

Set the parameters of the mixture model.

It is assumed that the array params store for each class the shapes and scales parameters on two consecutive rows. The number of column of params is the number of variables.

Definition at line 165 of file STK_CategoricalParameters.h.

166 {
167 int kp = params.beginRows();
168 for(int k=proba_.begin(); k<proba_.end(); ++k)
169 {
170 for (int l = proba_[k].beginRows(); l < proba_[k].endRows(); ++l, ++kp)
171 {
172 proba_[k][l] = 0.;
173 for (int j = params.beginCols(); j < params.endCols(); ++j)
174 { proba_[k][l] += params(kp , j) ;}
175 proba_[k][l] /= proba_[k].sizeCols();
176 }
177 }
178 }

◆ setStatistics()

set and release the computed statistics

Definition at line 137 of file STK_CategoricalParameters.cpp.

138{
139 for(int k=stat_proba_.begin(); k<stat_proba_.end(); ++k)
140 {
141 proba_[k] = stat_proba_[k].mean();
142 stat_proba_[k].release();
143 }
144}

◆ updateStatistics()

update statistics of the parameters.

Definition at line 131 of file STK_CategoricalParameters.cpp.

132{
133 for(int k=stat_proba_.begin(); k<stat_proba_.end(); ++k)
134 { stat_proba_[k].update(proba_[k]);}
135}
virtual void update()
update the runner.

Member Data Documentation

◆ proba_

array of size nbCluster with the probabilities of the variables

Definition at line 121 of file STK_CategoricalParameters.h.

◆ stat_proba_

array of size nbCluster with the statistics of the probabilities

Definition at line 123 of file STK_CategoricalParameters.h.


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