STK++ 0.9.13
STK_PoissonParameters.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/* default constructor
41 * @param nbCluster the number of class of the mixture
42 **/
44 : lambda_(nbCluster)
45 , stat_lambda_(nbCluster)
46{}
47/* copy constructor.
48 * @param param the parameters to copy.
49 **/
51 : lambda_(param.lambda_)
52 , stat_lambda_(param.stat_lambda_)
53{}
54/* destructor */
56/* resize the set of parameter */
58{
59 for (int k = lambda_.begin(); k< lambda_.end(); ++k)
60 {
61 lambda_[k].resize(range) = 1.;
62 stat_lambda_[k].resize(range);
63 }
64}
65/* update statistics of the parameters. */
67{
68 for(int k=stat_lambda_.begin(); k<stat_lambda_.end(); ++k)
69 { stat_lambda_[k].update(lambda_[k]);}
70}
71/* Set the computed statistics */
73{
74 for(int k=stat_lambda_.begin(); k<stat_lambda_.end(); ++k)
75 {
76 lambda_[k] = stat_lambda_[k].mean();
77 stat_lambda_[k].release();
78 }
79}
80/* Release the computed statistics */
82{
83 for(int k=stat_lambda_.begin(); k<stat_lambda_.end(); ++k)
84 { stat_lambda_[k].release();}
85}
86
87
88/* default constructor
89 * @param nbCluster the number of class of the mixture
90 **/
92 : lambdak_(nbCluster), lambdaj_()
93 , stat_lambdak_(nbCluster), stat_lambdaj_()
94{}
95/* copy constructor.
96 * @param param the parameters to copy.
97 **/
99 : lambdak_(param.lambdak_)
100 , lambdaj_(param.lambdaj_)
101 , stat_lambdak_(param.stat_lambdak_)
102 , stat_lambdaj_(param.stat_lambdaj_)
103{}
104/* destructor */
106/* resize the set of parameter */
108{
109 for (int k = lambdak_.begin(); k< lambdak_.end(); ++k)
110 {
111 lambdak_[k] = 1.;
112 stat_lambdak_[k].release();
113 }
114 lambdaj_.resize(range) = 1;
115 stat_lambdaj_.resize(range);
116}
117
118/* update statistics of the parameters. */
120{
121 for(int k=stat_lambdak_.begin(); k<stat_lambdak_.end(); ++k)
122 { stat_lambdak_[k].update(lambdak_[k]);}
123 stat_lambdaj_.update(lambdaj_);
124}
125/* Set the computed statistics */
127{
128 for(int k=stat_lambdak_.begin(); k<stat_lambdak_.end(); ++k)
129 {
130 lambdak_[k] = stat_lambdak_[k].mean();
131 stat_lambdak_[k].release();
132 }
133 lambdaj_ = stat_lambdaj_.mean();
134 stat_lambdaj_.release();
135
136}
137/* Release the computed statistics */
139{
140 for(int k=stat_lambdak_.begin(); k<stat_lambdak_.end(); ++k)
141 { stat_lambdak_[k].release();}
142 stat_lambdaj_.release();
143}
144
145/* default constructor
146 * @param nbCluster the number of class of the mixture
147 **/
149 : lambda_(nbCluster), stat_lambda_(nbCluster)
150{}
151/* copy constructor.
152 * @param param the parameters to copy.
153 **/
155 : lambda_(param.lambda_), stat_lambda_(param.stat_lambda_)
156{}
157/* destructor */
159/* resize the set of parameter */
161{
162 for (int k = lambda_.begin(); k< lambda_.end(); ++k)
163 { lambda_[k] = 1.;
164 stat_lambda_[k].release();
165 }
166}
167
168/* update statistics of the parameters. */
170{
171 for(int k=stat_lambda_.begin(); k<stat_lambda_.end(); ++k)
172 { stat_lambda_[k].update(lambda_[k]);}
173}
174/* Set the computed statistics */
176{
177 for(int k=stat_lambda_.begin(); k<stat_lambda_.end(); ++k)
178 {
179 lambda_[k] = stat_lambda_[k].mean();
180 stat_lambda_[k].release();
181 }
182}
183/* Release the computed statistics */
185{
186 for(int k=stat_lambda_.begin(); k<stat_lambda_.end(); ++k)
187 { stat_lambda_[k].release();}
188}
189
190} // namespace STK
191
In this file we define the Parameters classes for Poisson mixture models.
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.