STK++ 0.9.13
STK_CategoricalParameters.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._DOT_I..._AT_stkpp.org (see copyright for ...)
23*/
24
25/*
26 * Project: stkpp::Clustering
27 * created on: Oct 24, 2013
28 * Author: Serge Iovleff
29 **/
30
36#ifndef STK_CATEGORICALPARAMETERS_H
37#define STK_CATEGORICALPARAMETERS_H
38
39#include "../STK_Clust_Util.h"
40
44
46
47namespace STK
48{
49
53template<>
54struct ModelParameters<Clust::Categorical_pjk_>
55{
63 ModelParameters(int nbCluster);
67 ModelParameters( ModelParameters const& param);
73 ModelParameters& operator=( ModelParameters const& param);
74
75 // getters
77 inline Real const& proba(int k, int j, int l) const { return proba_[k](l,j);}
79 inline CVectorX proba(int k, int j) const { return proba_[k].col(j);}
80
85 void resize(Range const& rangeModalities, Range const& rangeCols);
86
88 void updateStatistics();
90 void setStatistics();
92 void releaseStatistics();
93
99 template<class Array>
101 {
102 int kp = params.beginRows();
103 for(int k=proba_.begin(); k<proba_.end(); ++k)
104 {
105 for (int l = proba_[k].beginRows(); l < proba_[k].endRows(); ++l, ++kp)
106 {
107 for (int j = proba_[k].beginCols(); j < proba_[k].endCols(); ++j)
108 { proba_[k](l, j) = params(kp , j) ;}
109 }
110 }
111 }
112};
113
117template<>
118struct ModelParameters<Clust::Categorical_pk_>
119{
124
128 ModelParameters(int nbCluster);
132 ModelParameters( ModelParameters const& param);
138 ModelParameters& operator=( ModelParameters const& param);
139
140 // getters
142 inline Real const& proba(int k, int j, int l) const { return proba_[k][l];}
144 inline CVectorX proba(int k, int j) const { return proba_[k];}
145
150 void resize(Range const& rangeModalities, Range const& rangeCols);
151
153 void updateStatistics();
155 void setStatistics();
157 void releaseStatistics();
158
164 template<class Array>
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 }
179};
180
181
182} // namespace STK
183
184#endif /* STK_CATEGORICALPARAMETERS_H */
In this file we define and implement the final class Array1D.
In this file we implement the final class CArrayVector.
In this file we implement the final class CArray.
This file contain the definition and implementation of the Online classes.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Index sub-vector region: Specialization when the size is unknown.
Definition STK_Range.h:265
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.
void setParameters(ExprBase< Array > const &params)
Set the parameters of the mixture model.
Array1D< CArrayXX > proba_
array of size nbCluster with the probabilities of the variables
Array1D< Stat::Online< CArrayXX, Real > > stat_proba_
Array of size nbCluster with the statistics of the probabilities.
Real const & proba(int k, int j, int l) const
void setParameters(ExprBase< Array > const &params)
Set the parameters of the mixture model.
Real const & proba(int k, int j, int l) const
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
struct storing the parameters of the mixture.