35#ifndef STK_CATEGORICAL_PJK_H
36#define STK_CATEGORICAL_PJK_H
38#include "../CategoricalModels/STK_CategoricalBase.h"
44template<
class Array>
class Categorical_pjk;
101 for (
int k = p_tik->beginCols(); k < p_tik->endCols(); ++k)
103 param_.proba_[k].randUnif();
104 for (
int j=param_.proba_[k].beginCols();
j< param_.proba_[k].endCols(); ++
j)
105 { param_.proba_[k].col(
j) /= param_.proba_[k].col(
j).sum();}
114 for (
int k = p_tik->beginCols(); k < p_tik->endCols(); ++k)
116 param_.proba_[k] = 0.;
117 for (
int j = p_data()->beginCols();
j < p_data()->endCols(); ++
j)
120 for (
int i = p_data()->beginRows();
i < p_data()->endRows(); ++
i)
121 { param_.proba_[k](p_data()->elt(
i,
j),
j) += p_tik->elt(
i, k);}
124 if (
sum) { param_.proba_[k].col(
j) /=
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
PointXi nbModalities_
Array with the number of modalities of each columns of the data set.
The diagonal Categorical mixture model Categorical_pjk is the most general diagonal Categorical model...
bool run(CArrayXX const *const &p_tik, CPointX const *const &p_tk)
Compute the weighted probabilities.
CategoricalBase< Categorical_pjk< Array > > Base
Categorical_pjk(Categorical_pjk const &model)
copy constructor
Categorical_pjk(int nbCluster)
default constructor
int computeNbFreeParameters() const
void randomInit(CArrayXX const *const &p_tik, CPointX const *const &p_tk)
Initialize randomly the parameters of the Categorical mixture.
~Categorical_pjk()
destructor
hidden::CSlice< Derived, sizeRows_, 1 >::Result col(int j) const
implement the col operator using a reference on the column of the allocator
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
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_pjk_ > Parameters
Type of the structure storing the parameters of a Categorical_pjk model.
Main class for the mixtures traits policy.