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
36
#include <
Clustering/include/PoissonModels/STK_PoissonParameters.h
>
37
38
namespace
STK
39
{
40
/* default constructor
41
* @param nbCluster the number of class of the mixture
42
**/
43
ModelParameters<Clust::Poisson_ljk_>::ModelParameters
(
int
nbCluster)
44
: lambda_(nbCluster)
45
, stat_lambda_(nbCluster)
46
{}
47
/* copy constructor.
48
* @param param the parameters to copy.
49
**/
50
ModelParameters<Clust::Poisson_ljk_>::ModelParameters
(
ModelParameters
const
& param)
51
: lambda_(param.lambda_)
52
, stat_lambda_(param.stat_lambda_)
53
{}
54
/* destructor */
55
ModelParameters<Clust::Poisson_ljk_>::~ModelParameters
() {}
56
/* resize the set of parameter */
57
void
ModelParameters<Clust::Poisson_ljk_>::resize
(
Range
const
& range)
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. */
66
void
ModelParameters<Clust::Poisson_ljk_>::updateStatistics
()
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 */
72
void
ModelParameters<Clust::Poisson_ljk_>::setStatistics
()
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 */
81
void
ModelParameters<Clust::Poisson_ljk_>::releaseStatistics
()
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
**/
91
ModelParameters<Clust::Poisson_ljlk_>::ModelParameters
(
int
nbCluster)
92
: lambdak_(nbCluster), lambdaj_()
93
, stat_lambdak_(nbCluster), stat_lambdaj_()
94
{}
95
/* copy constructor.
96
* @param param the parameters to copy.
97
**/
98
ModelParameters<Clust::Poisson_ljlk_>::ModelParameters
(
ModelParameters
const
& param)
99
: lambdak_(param.lambdak_)
100
, lambdaj_(param.lambdaj_)
101
, stat_lambdak_(param.stat_lambdak_)
102
, stat_lambdaj_(param.stat_lambdaj_)
103
{}
104
/* destructor */
105
ModelParameters<Clust::Poisson_ljlk_>::~ModelParameters
() {}
106
/* resize the set of parameter */
107
void
ModelParameters<Clust::Poisson_ljlk_>::resize
(
Range
const
& range)
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. */
119
void
ModelParameters<Clust::Poisson_ljlk_>::updateStatistics
()
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 */
126
void
ModelParameters<Clust::Poisson_ljlk_>::setStatistics
()
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 */
138
void
ModelParameters<Clust::Poisson_ljlk_>::releaseStatistics
()
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
**/
148
ModelParameters<Clust::Poisson_lk_>::ModelParameters
(
int
nbCluster)
149
: lambda_(nbCluster), stat_lambda_(nbCluster)
150
{}
151
/* copy constructor.
152
* @param param the parameters to copy.
153
**/
154
ModelParameters<Clust::Poisson_lk_>::ModelParameters
(
ModelParameters
const
& param)
155
: lambda_(param.lambda_), stat_lambda_(param.stat_lambda_)
156
{}
157
/* destructor */
158
ModelParameters<Clust::Poisson_lk_>::~ModelParameters
() {}
159
/* resize the set of parameter */
160
void
ModelParameters<Clust::Poisson_lk_>::resize
(
Range
const
& range)
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. */
169
void
ModelParameters<Clust::Poisson_lk_>::updateStatistics
()
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 */
175
void
ModelParameters<Clust::Poisson_lk_>::setStatistics
()
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 */
184
void
ModelParameters<Clust::Poisson_lk_>::releaseStatistics
()
185
{
186
for
(
int
k=stat_lambda_.begin(); k<stat_lambda_.end(); ++k)
187
{ stat_lambda_[k].release();}
188
}
189
190
}
// namespace STK
191
STK_PoissonParameters.h
In this file we define the Parameters classes for Poisson mixture models.
STK::TRange< UnknownSize >
Index sub-vector region: Specialization when the size is unknown.
Definition
STK_Range.h:265
STK
The namespace STK is the main domain space of the Statistical ToolKit project.
STK::ModelParameters
struct storing the parameters of the mixture.
Definition
STK_Clust_Util.h:60
projects
Clustering
src
STK_PoissonParameters.cpp
Generated on Sat Feb 15 2025 12:07:15 for STK++ by
1.9.8