38#if STK_MIXTURE_DEBUG | STK_MIXTURE_VERBOSE | STK_MIXTURE_VERY_VERBOSE
51 , state_(Clust::modelCreated_)
60 , state_(
model.state_)
62 , lnComp_(
model.lnComp_)
76#ifdef STK_MIXTURE_VERBOSE
77 stk_cout <<
_T(
"Entering IMixtureComposer::initializeStep\n");
95#ifdef STK_MIXTURE_VERBOSE
96 stk_cout <<
_T(
"IMixtureComposer::initializeStep done\n");
98#ifdef STK_MIXTURE_VERY_VERBOSE
107#ifdef STK_MIXTURE_VERY_VERBOSE
108 stk_cout <<
_T(
"Entering IMixtureComposer::randomClassInit()\n");
120#ifdef STK_MIXTURE_VERY_VERBOSE
121 stk_cout <<
_T(
"IMixtureComposer::randomClassInit() done\n");
128#ifdef STK_MIXTURE_VERBOSE
129 stk_cout <<
_T(
"Entering IMixtureComposer::randomFuzzyInit(). state= ") <<
state() <<
_T(
"\n");
143#ifdef STK_MIXTURE_VERBOSE
144 stk_cout <<
_T(
"IMixtureComposer::randomFuzzyInit() done\n");
151#ifdef STK_MIXTURE_VERY_VERBOSE
152 stk_cout <<
_T(
"Entering IMixtureComposer::cStep()\n");
154 for (
int i=
tik_.beginRows();
i <
tik_.endRows();
i++)
158#ifdef STK_MIXTURE_VERY_VERBOSE
160 stk_cout <<
_T(
"IMixtureComposer::cStep() done\n");
169#ifdef STK_MIXTURE_VERY_VERBOSE
170 stk_cout <<
_T(
"Entering IMixtureComposer::sStep()\n");
174#ifdef STK_MIXTURE_VERY_VERBOSE
175 stk_cout <<
_T(
"IMixtureComposer::sStep() done\n");
182#ifdef STK_MIXTURE_VERY_VERBOSE
183 stk_cout <<
_T(
"Entering IMixtureComposer::eStep()\n");
188#pragma omp parallel for reduction (+:sum)
195#ifdef STK_MIXTURE_VERY_VERBOSE
196 stk_cout <<
_T(
"IMixtureComposer::eStep() lnLikelihood =") <<
sum <<
_T(
"\n");
197 stk_cout <<
_T(
"IMixtureComposer::eStep() done\n");
207 for (
int i =
zi_.begin();
i<
zi_.end(); ++
i)
229 for (
int k=
tik_.beginCols(); k<
tik_.endCols(); k++)
233#ifdef STK_MIXTURE_VERY_VERBOSE
234 stk_cout <<
_T(
"IMixtureComposer::eStep(") <<
i <<
_T(
")\n");
238 for (
int k=
tik_.beginCols(); k<
tik_.endCols(); k++)
241 stk_cout <<
_T(
"lnComponentProbability(") <<
i <<
_T(
",")<< k <<
_T(
")=") << val <<
_T(
"\n");
255 return max + std::log(
sum );
292#ifdef STK_MIXTURE_VERBOSE
293 stk_cout <<
_T(
"Entering IMixtureComposer::initializeMixtureParameters\n");
305 for (
int i =
tik_.beginRows();
i <
tik_.endRows(); ++
i)
This file define methods for displaying Arrays and Expressions.
In this file we define the abstract base class for mixture models.
In this file we define the Categorical distribution.
This file contain the functors computings statistics.
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
TransposeOperator< Derived > const transpose() const
Derived & randUnif()
set random values to this using a uniform law.
Derived & rand(Law::IUnivLaw< Type > const &law)
set random values to this using a distribution law given by the user.
Type const maxElt(int &row, int &col) const
Type const minElt(int &row, int &col) const
UnaryOperator< IsInfiniteOp< Type >, Derived > isInfinite() const
hidden::CSlice< Derived, 1, sizeCols_ >::Result row(int i) const
implement the row operator using a reference on the row of the allocator
Base class for Mixture (composed) model.
virtual ~IMixtureComposer()
destructor
virtual int cStep()
Replace tik by zik.
virtual void initializeStep()
Initialize the model before its first use.
void setState(Clust::modelState state)
set the state of the model : should be used by any strategy
void randomFuzzyInit()
Initialize randomly the posterior probabilities tik of the model, then compute the zi values with map...
virtual void pStep()
Compute proportions using the ML estimates, default implementation.
virtual Real eStep()
compute the zi, the lnLikelihood of the current estimates and the next value of the tik.
CPointX lnComp_
Auxiliary array used in the eStep.
virtual int randomZi()
generate random zi_
virtual void initializeMixtureParameters()
Create the mixture model parameters pk_ and tik_.
virtual void mapStep()
Compute zi using the Map estimate.
IMixtureComposer(int nbSample, int nbCluster)
Constructor.
Clust::modelState state() const
void randomClassInit()
Initialize randomly the labels zi of the model.
virtual int sStep()
Simulate zi accordingly to tik and replace tik by zik by calling cStep().
virtual int randomTik()
generate random tik_
virtual void paramUpdateStep()=0
Compute the proportions and the model parameters given the current tik mixture parameters.
virtual void finalizeStep()
Finalize the estimation of the model.
Interface base class for Mixture (composed) model.
CArrayXX tik_
The tik probabilities.
virtual void writeParameters(ostream &os) const
write the parameters of the model in the stream os.
virtual Real lnComponentProbability(int i, int k) const =0
CVectorXi zi_
The zi class label.
Real computeLnLikelihood() const
virtual void initializeStep()
Initialize the model before at its first use.
int computeNbFreeParameters() const
compute the number of free parameters of the model.
CPointX pk_
The proportions of each mixtures.
CPointX tk_
The sum of the columns of tik_.
int nbCluster_
number of cluster.
void setNbFreeParameter(int const &nbFreeParameter)
set the number of free parameters of the model
void setLnLikelihood(Real const &lnLikelihood)
set the log-likelihood of the model
Categorical probability law.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
bool isFinite(Type const &x)
utility method allowing to know if a value is a finite value
Arrays::SumOp< Lhs, Rhs >::result_type sum(Lhs const &lhs, Rhs const &rhs)
convenience function for summing two arrays
@ modelInitialized_
the model is initialized and its parameters are initialized to default values
@ modelFinalized_
the model is finalized
@ modelParamInitialized_
The parameters of the model have been initialized.
double Real
STK fundamental type of Real values.
hidden::SliceVisitorSelector< Derived, hidden::MaxVisitor, Arrays::by_col_ >::type_result max(Derived const &A)
If A is a row-vector or a column-vector then the function will return the usual maximal value of the ...
hidden::FunctorTraits< Derived, SumOp >::Row sum(Derived const &A)
Compute the sum of A.
hidden::FunctorTraits< Derived, MeanOp >::Row meanByCol(Derived const &A)
hidden::FunctorTraits< Derived, SumOp >::Row sumByCol(Derived const &A)
The namespace STK is the main domain space of the Statistical ToolKit project.
hidden::SliceVisitorSelector< Derived, hidden::SumVisitor, Arrays::by_col_ >::type_result sumByCol(Derived const &A)