STK++ 0.9.13
STK::IMixture Class Referenceabstract

Interface base class for all the mixture models that will be processed by the composer. More...

#include <STK_IMixture.h>

Inheritance diagram for STK::IMixture:
Inheritance graph

Public Member Functions

 IMixture (String const &idData=String())
 Constructor with identification character.
 
 IMixture (IMixture const &mixture)
 copy constructor.
 
virtual ~IMixture ()
 Virtual destructor.
 
String constidData () const
 
IMixtureStatModel const *const p_composer () const
 
void setMixtureModel (IMixtureStatModel const *p_composer)
 set the mixture composer to the mixture
 
virtual IMixtureclone () const =0
 This is a standard clone function in usual sense.
 
virtual IMixturecreate () const =0
 This is a standard create function in usual sense.
 
virtual void initializeStep ()=0
 This function must be defined in derived class for initialization of the mixture parameters.
 
virtual void randomInit ()=0
 This function should be used in order to initialize randomly the parameters of the mixture.
 
virtual void paramUpdateStep ()=0
 This function is equivalent to mStep and must be defined to update parameters.
 
virtual Real lnComponentProbability (int sample_num, int Cluster_num)=0
 This function must be defined to return the posterior probability (PDF) for corresponding sample_num and Cluster_num.
 
virtual int nbFreeParameter () const =0
 This function must return the number of free parameters.
 
virtual int nbMissingValues () const =0
 This function must return the number of missing value in data set identified by idData_.
 
virtual void imputationStep ()
 This function should be used for Imputation of data.
 
virtual void samplingStep ()
 This function must be defined for simulation of all the latent variables and/or missing data excluding class labels.
 
virtual void storeIntermediateResults (int iteration)
 This function should be used to store any intermediate results during various iterations after the burn-in period.
 
virtual void releaseIntermediateResults ()
 This step can be used to signal to the mixtures that they must release the stored results.
 
virtual void setParametersStep ()
 set the parameters of the model.
 
virtual void finalizeStep ()
 This step can be used by developer to finalize any thing.
 
virtual void writeParameters (std::ostream &out) const
 This function can be used to write summary of parameters on to the output stream.
 

Protected Member Functions

int nbSample () const
 This function can be used in derived classes to get number of samples.
 
int nbCluster () const
 This function can be used in derived classes to get number of classes.
 
CPointX constp_pk () const
 This function can be used in derived classes to get estimated number of individuals from the framework.
 
CPointX constp_tk () const
 This function can be used in derived classes to get proportions from the framework.
 
CArrayXX constp_tik () const
 This function can be used in derived classes to get posterior probabilities from the framework.
 
CVectorXi constp_zi () const
 This function can be used in derived classes to get class labels from the framework.
 

Private Attributes

const IMixtureStatModelp_composer_
 pointer on the main composer model
 
String idData_
 Id name of the mixture.
 

Detailed Description

Interface base class for all the mixture models that will be processed by the composer.

Any mixture that can be used and add to a mixed model have to implement the pure virtual methods defined in this interface. With each mixture is associated a data set identified by an idData string.

Using an idData is not mandatory but is useful in case data set is stored in a DataHandler.

See also
STK::IDataHandler

Definition at line 64 of file STK_IMixture.h.

Constructor & Destructor Documentation

◆ IMixture() [1/2]

STK::IMixture::IMixture ( String const idData = String())

Constructor with identification character.

Parameters
idDataIdentification string of the data associated to this mixture.
Note
The Id is provided by the framework if the associated data set is in a STK::IDataHandler struct.

Definition at line 45 of file STK_IMixture.cpp.

47{}
const IMixtureStatModel * p_composer_
pointer on the main composer model
String idData_
Id name of the mixture.
String const & idData() const

◆ IMixture() [2/2]

STK::IMixture::IMixture ( IMixture const mixture)

copy constructor.

Warning
The pointer on the composer is not copied and is set to 0: it has to be set again.
Parameters
mixturethe mixture to copy

Definition at line 50 of file STK_IMixture.cpp.

51 : p_composer_(0)
52 , idData_(mixture.idData_)
53{}

◆ ~IMixture()

STK::IMixture::~IMixture ( )
virtual

Virtual destructor.

Definition at line 55 of file STK_IMixture.cpp.

55{}

Member Function Documentation

◆ clone()

virtual IMixture * STK::IMixture::clone ( ) const
pure virtual

This is a standard clone function in usual sense.

It must be defined to provide new object of your class with values of various parameters equal to the values of calling object. In other words, this is equivalent to polymorphic copy constructor.

Returns
New instance of class as that of calling object.

Implemented in STK::CategoricalBridge< Id, Data >, STK::DiagGaussianBridge< Id, Data >, STK::GammaBridge< Id, Data >, STK::HDMatrixGaussianBridge< IdRow, IdCol, Data >, STK::HDGaussianBridge< Id, Data >, STK::KmmBridge< Id, Data >, and STK::PoissonBridge< Id, Data >.

◆ create()

virtual IMixture * STK::IMixture::create ( ) const
pure virtual

This is a standard create function in usual sense.

It must be defined to provide new object of your class with correct behavior. In other words, this is equivalent to virtual constructor.

Returns
New instance of class as that of calling object.

Implemented in STK::CategoricalBridge< Id, Data >, STK::DiagGaussianBridge< Id, Data >, STK::GammaBridge< Id, Data >, STK::HDMatrixGaussianBridge< IdRow, IdCol, Data >, STK::HDGaussianBridge< Id, Data >, STK::KmmBridge< Id, Data >, and STK::PoissonBridge< Id, Data >.

◆ finalizeStep()

virtual void STK::IMixture::finalizeStep ( )
inlinevirtual

◆ idData()

◆ imputationStep()

◆ initializeStep()

virtual void STK::IMixture::initializeStep ( )
pure virtual

This function must be defined in derived class for initialization of the mixture parameters.

This method should create any container needed by the model, resize them and initialize them. Since this method can be used when create is called, its main purpose should be to reset the mixture parameters, while leaving the data unchanged. This function will be called once the model is created and data is set.

Implemented in STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.

◆ lnComponentProbability()

virtual Real STK::IMixture::lnComponentProbability ( int  sample_num,
int  Cluster_num 
)
pure virtual

This function must be defined to return the posterior probability (PDF) for corresponding sample_num and Cluster_num.

Parameters
sample_numSample number
Cluster_numCluster number
Returns
the value of component probability in log scale

Implemented in STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.

◆ nbCluster()

int STK::IMixture::nbCluster ( ) const
protected

◆ nbFreeParameter()

◆ nbMissingValues()

◆ nbSample()

int STK::IMixture::nbSample ( ) const
protected

This function can be used in derived classes to get number of samples.

Returns
Number of samples.

Definition at line 64 of file STK_IMixture.cpp.

64{ return p_composer_->nbSample();}

References p_composer_.

◆ p_composer()

IMixtureStatModel const *const STK::IMixture::p_composer ( ) const
inline
Returns
A constant pointer on the composer.

Definition at line 84 of file STK_IMixture.h.

84{ return p_composer_;}

References p_composer_.

Referenced by STK::IMixtureBridge< Derived >::initializeStep(), and setMixtureModel().

◆ p_pk()

CPointX const * STK::IMixture::p_pk ( ) const
protected

This function can be used in derived classes to get estimated number of individuals from the framework.

Returns
Pointer to the number of individuals.

Definition at line 73 of file STK_IMixture.cpp.

73{ return &(p_composer_->pk());}

References p_composer_.

◆ p_tik()

CArrayXX const * STK::IMixture::p_tik ( ) const
protected

This function can be used in derived classes to get posterior probabilities from the framework.

Returns
Pointer to tik.

Definition at line 81 of file STK_IMixture.cpp.

81{ return &(p_composer_->tik());}

References p_composer_.

Referenced by STK::IMixtureBridge< Derived >::paramUpdateStep(), STK::IMixtureBridge< Derived >::randomInit(), and STK::IMixtureBridge< Derived >::writeParameters().

◆ p_tk()

CPointX const * STK::IMixture::p_tk ( ) const
protected

This function can be used in derived classes to get proportions from the framework.

Returns
Pointer to proportions.

Definition at line 77 of file STK_IMixture.cpp.

77{ return &(p_composer_->tk());}

References p_composer_.

Referenced by STK::IMixtureBridge< Derived >::paramUpdateStep(), and STK::IMixtureBridge< Derived >::randomInit().

◆ p_zi()

CVectorXi const * STK::IMixture::p_zi ( ) const
protected

This function can be used in derived classes to get class labels from the framework.

Returns
Pointer to zi.

Definition at line 85 of file STK_IMixture.cpp.

85{ return &(p_composer_->zi());}

References p_composer_.

◆ paramUpdateStep()

◆ randomInit()

◆ releaseIntermediateResults()

virtual void STK::IMixture::releaseIntermediateResults ( )
inlinevirtual

◆ samplingStep()

virtual void STK::IMixture::samplingStep ( )
inlinevirtual

This function must be defined for simulation of all the latent variables and/or missing data excluding class labels.

The class labels will be simulated by the framework itself because to do so we have to take into account all the mixture laws.

Do nothing by default

Reimplemented in STK::KmmBridge< Id, Data >, STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.

Definition at line 146 of file STK_IMixture.h.

146{};

◆ setMixtureModel()

void STK::IMixture::setMixtureModel ( IMixtureStatModel const p_composer)

set the mixture composer to the mixture

Parameters
p_composerthe composer to set

Definition at line 58 of file STK_IMixture.cpp.

IMixtureStatModel const *const p_composer() const

References p_composer(), and p_composer_.

◆ setParametersStep()

virtual void STK::IMixture::setParametersStep ( )
inlinevirtual

set the parameters of the model.

This function should be used to set the parameters computed using the intermediate results. This method will be called after the long-run and before the finalize step.

Do nothing by default

Reimplemented in STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.

Definition at line 163 of file STK_IMixture.h.

163{}

◆ storeIntermediateResults()

virtual void STK::IMixture::storeIntermediateResults ( int  iteration)
inlinevirtual

This function should be used to store any intermediate results during various iterations after the burn-in period.

Parameters
iterationProvides the iteration number beginning after the burn-in period.

Do nothing by default

Reimplemented in STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.

Definition at line 152 of file STK_IMixture.h.

152{}

◆ writeParameters()

virtual void STK::IMixture::writeParameters ( std::ostream &  out) const
inlinevirtual

This function can be used to write summary of parameters on to the output stream.

Parameters
outStream where you want to write the summary of parameters.

Definition at line 171 of file STK_IMixture.h.

172 {
173#ifdef STK_MIXTURE_DEBUG
174 stk_cout<< _T("You need to override this method in your mixture!");
175#endif
176 }
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.

References _T, and stk_cout.

Member Data Documentation

◆ idData_

String STK::IMixture::idData_
private

Id name of the mixture.

Definition at line 209 of file STK_IMixture.h.

Referenced by idData().

◆ p_composer_

const IMixtureStatModel* STK::IMixture::p_composer_
private

pointer on the main composer model

Definition at line 207 of file STK_IMixture.h.

Referenced by nbCluster(), nbSample(), p_composer(), p_pk(), p_tik(), p_tk(), p_zi(), and setMixtureModel().


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