35#ifndef STK_CATEGORICAL_PK_H
36#define STK_CATEGORICAL_PK_H
38#include "../CategoricalModels/STK_CategoricalBase.h"
44template<
class Array>
class Categorical_pk;
104 for (
int k = p_tik->beginCols(); k < p_tik->endCols(); ++k)
106 param_.proba_[k].randUnif();
107 param_.proba_[k] /= param_.proba_[k].sum();
115 for (
int k = p_tik->beginCols(); k < p_tik->endCols(); ++k)
117 param_.proba_[k] = 0.;
118 for (
int j = p_data()->beginCols();
j < p_data()->endCols(); ++
j)
120 for (
int i = p_tik->beginRows();
i < p_tik->endRows(); ++
i)
121 { param_.proba_[k][(*p_data())(
i,
j)] += (*p_tik)(
i, k);}
123 Real sum = param_.proba_[k].sum();
124 if (
sum<=0.)
return false;
125 param_.proba_[k] /=
sum;
Base class for the Categorical models.
Array const *const & p_data() const
Parameters param_
parameters of the derived mixture model.
Range modalities_
range of the modalities
The diagonal Categorical mixture model Categorical_pk is a diagonal Categorical model and has a densi...
int computeNbFreeParameters() const
void randomInit(CArrayXX const *const &p_tik, CPointX const *const &p_tk)
Initialize randomly the parameters of the Categorical mixture.
Categorical_pk(int nbCluster)
default constructor
~Categorical_pk()
destructor
bool run(CArrayXX const *const &p_tik, CPointX const *const &p_tk)
Compute the weighted proportions of each class.
CategoricalBase< Categorical_pk< Array > > Base
Categorical_pk(Categorical_pk const &model)
copy constructor
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
int size() const
get the size of the TRange (the number of elements).
Arrays::SumOp< Lhs, Rhs >::result_type sum(Lhs const &lhs, Rhs const &rhs)
convenience function for summing two arrays
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.
ModelParameters< Clust::Categorical_pk_ > Parameters
Type of the structure storing the parameters of a Categorical_pk model.
Main class for the mixtures traits policy.