STK++ 0.9.13
STK_CategoricalParameters.cpp
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
37
38namespace STK
39{
40
41/*------------------Categorical_pjk_--------------- */
42/* default constructor
43 * @param nbCluster the number of class of the mixture
44 **/
46 : proba_(nbCluster), stat_proba_(nbCluster) {}
47/* copy constructor.
48 * @param param the parameters to copy.
49 **/
51 : proba_(param.proba_), stat_proba_(param.stat_proba_)
52{}
53/* copy operator.
54 * @param param the parameters to copy.
55 **/
57{
58 proba_ = param.proba_;
59 stat_proba_ = param.stat_proba_;
60 return *this;
61}
62/* destructor */
64/* resize the set of parameter */
66{
67 for (int k = proba_.begin(); k< proba_.end(); ++k)
68 {
69 proba_[k].resize(rangeModalities, rangeCols) = 1./rangeModalities.size();
70 stat_proba_[k].resize(rangeModalities, rangeCols);
71 }
72}
73
74/* update statistics of the parameters. */
76{
77 for(int k=stat_proba_.begin(); k<stat_proba_.end(); ++k)
78 { stat_proba_[k].update(proba_[k]);}
79}
80/* set and release the computed statistics */
82{
83 for(int k=stat_proba_.begin(); k<stat_proba_.end(); ++k)
84 {
85 proba_[k] = stat_proba_[k].mean();
86 stat_proba_[k].release();
87 }
88}
89
90/* Set the computed statistics */
92{
93 for(int k=stat_proba_.begin(); k<stat_proba_.end(); ++k)
94 { stat_proba_[k].release();}
95}
96
97/*------------------Categorical_pk_--------------- */
98/* default constructor
99 * @param nbCluster the number of class of the mixture
100 **/
102 : proba_(nbCluster), stat_proba_(nbCluster) {}
103/* copy constructor.
104 * @param param the parameters to copy.
105 **/
107 : proba_(param.proba_), stat_proba_(param.stat_proba_)
108{}
109/* destructor */
111/* copy operator.
112 * @param param the parameters to copy.
113 **/
115{
116 proba_ = param.proba_;
117 stat_proba_ = param.stat_proba_;
118 return *this;
119}
120
121/* resize the set of parameter */
123{
124 for (int k = proba_.begin(); k< proba_.end(); ++k)
125 {
126 proba_[k].resize(rangeModalities) = 1./rangeModalities.size();
127 stat_proba_[k].resize(rangeModalities);
128 }
129}
130/* update statistics of the parameters. */
132{
133 for(int k=stat_proba_.begin(); k<stat_proba_.end(); ++k)
134 { stat_proba_[k].update(proba_[k]);}
135}
136/* set the computed statistics */
138{
139 for(int k=stat_proba_.begin(); k<stat_proba_.end(); ++k)
140 {
141 proba_[k] = stat_proba_[k].mean();
142 stat_proba_[k].release();
143 }
144}
145/* release the computed statistics */
147{
148 for(int k=stat_proba_.begin(); k<stat_proba_.end(); ++k)
149 { stat_proba_[k].release();}
150}
151
152} // namespace STK
153
In this file we define the Parameters classes for categorical mixture models.
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
The namespace STK is the main domain space of the Statistical ToolKit project.
struct storing the parameters of the mixture.