STK++ 0.9.13
STK_KernelParameters.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, 2014
28 * Author: Serge Iovleff
29 **/
30
38
39namespace STK
40{
41/* default constructor
42 * @param nbCluster the number of class of the mixture
43 **/
45 : sigma2_(1.), dim_(nbCluster, 10)
46 , stat_sigma2_(), stat_dim_(nbCluster)
47{}
48/* copy constructor.
49 * @param param the parameters to copy.
50 **/
52 : sigma2_(param.sigma2_), dim_(param.dim_)
53 , stat_sigma2_(param.stat_sigma2_)
54 , stat_dim_(param.stat_dim_)
55{}
56/* destructor */
58
59/* update statistics of the parameters. */
61{
62 stat_sigma2_.update(sigma2_);
63 for(int k=stat_dim_.begin(); k<stat_dim_.end(); ++k)
64 { stat_dim_[k].update(dim_[k]);}
65}
66/* Set the computed statistics */
68{
69 sigma2_ = stat_sigma2_.mean();
70 stat_sigma2_.release();
71 for(int k=stat_dim_.begin(); k<stat_dim_.end(); ++k)
72 {
73 dim_[k] = stat_dim_[k].mean();
74 stat_dim_[k].release();
75 }
76}
77/* Release the computed statistics */
79{
80 stat_sigma2_.release();
81 for(int k=stat_dim_.begin(); k<stat_dim_.end(); ++k)
82 { stat_dim_[k].release();}
83}
84
85
86/* default constructor
87 * @param nbCluster the number of class of the mixture
88 **/
90 : sigma2_(nbCluster, 1.), dim_(nbCluster, 10)
91 , stat_sigma2_(nbCluster), stat_dim_(nbCluster)
92{}
93/* copy constructor.
94 * @param param the parameters to copy.
95 **/
97 : sigma2_(param.sigma2_), dim_(param.dim_)
98 , stat_sigma2_(param.stat_sigma2_)
99 , stat_dim_(param.stat_dim_)
100{}
101/* destructor */
103
104/* update statistics of the parameters. */
106{
107 for(int k=stat_dim_.begin(); k<stat_dim_.end(); ++k)
108 {
109 stat_sigma2_[k].update(sigma2_[k]);
110 stat_dim_[k].update(dim_[k]);}
111}
112/* Set the computed statistics */
114{
115 for(int k=stat_dim_.begin(); k<stat_dim_.end(); ++k)
116 {
117 sigma2_[k] = stat_sigma2_[k].mean();
118 stat_sigma2_[k].release();
119 dim_[k] = stat_dim_[k].mean();
120 stat_dim_[k].release();
121 }
122}
123/* Release the computed statistics */
125{
126 for(int k=stat_dim_.begin(); k<stat_dim_.end(); ++k)
127 {
128 stat_sigma2_[k].release();
129 stat_dim_[k].release();
130 }
131}
132
133
134} // namespace STK
In this file we define the Parameters classes for kernel mixture models.
The namespace STK is the main domain space of the Statistical ToolKit project.
struct storing the parameters of the mixture.