STK++ 0.9.13
STK_GammaParameters.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_GAMMAPARAMETERS_H
37#define STK_GAMMAPARAMETERS_H
38
39#include "../STK_Clust_Util.h"
40
43
45
46namespace STK
47{
69
73template<>
74struct ModelParameters<Clust::Gamma_a_bjk_>: ParametersGammaBase
75{
84
88 ModelParameters(int nbCluster);
92 ModelParameters( ModelParameters const& param);
95
97 inline Real const& shape(int k, int j) const { return shape_;}
99 inline Real const& scale(int k, int j) const { return scale_[k][j];}
100
104 void resize(Range const& range);
105
107 void updateStatistics();
109 void setStatistics();
111 void releaseStatistics();
112
118 template<class Array>
120 {
121 shape_ = 0.;
122 for(int k=scale_.begin(), kp= params.beginRows(); k<scale_.end(); ++k, kp+=2)
123 {
124 shape_ += params.row(kp).mean();
125 scale_[k] = params.row(kp+1);
126 }
127 shape_ /= scale_.size();
128 }
129};
130
134template<>
135struct ModelParameters<Clust::Gamma_a_bk_>: public ParametersGammaBase
136{
145
149 ModelParameters(int nbCluster);
153 ModelParameters( ModelParameters const& param);
156
158 inline Real const& shape(int k, int j) const { return shape_;}
160 inline Real const& scale(int k, int j) const { return scale_[k];}
161
165 void resize(Range const& range);
166
168 void updateStatistics();
170 void setStatistics();
172 void releaseStatistics();
173
179 template<class Array>
181 {
182 shape_ = 0.;
183 for(int k=scale_.begin(), kp= params.beginRows(); k<scale_.end(); ++k, kp+=2)
184 {
185 shape_ += params.row(kp).mean();
186 scale_[k] = params.row(kp+1).mean();
187 }
188 shape_ /= scale_.size();
189 }
190};
191
195template<>
196struct ModelParameters<Clust::Gamma_aj_bjk_>: public ParametersGammaBase
197{
206
210 ModelParameters(int nbCluster);
214 ModelParameters( ModelParameters const& param);
217
219 inline Real const& shape(int k, int j) const { return shape_[k];}
221 inline Real const& scale(int k, int j) const { return scale_[k][j];}
222
226 void resize(Range const& range);
227
229 void updateStatistics();
231 void setStatistics();
233 void releaseStatistics();
234
240 template<class Array>
242 {
243 shape_ = 0.;
244 for(int k=scale_.begin(), kp= params.beginRows(); k<scale_.end(); ++k, kp+=2)
245 {
246 shape_ += params.row(kp);
247 scale_[k] = params.row(kp+1);
248 }
249 shape_ /= scale_.size();
250 }
251};
252
256template<>
257struct ModelParameters<Clust::Gamma_aj_bk_>: public ParametersGammaBase
258{
267
271 ModelParameters(int nbCluster);
275 ModelParameters( ModelParameters const& param);
278
280 inline Real const& shape(int k, int j) const { return shape_[j];}
282 inline Real const& scale(int k, int j) const { return scale_[k];}
283
287 void resize(Range const& range);
288
290 void updateStatistics();
292 void setStatistics();
294 void releaseStatistics();
295
301 template<class Array>
303 {
304 shape_ = 0.;
305 for(int k=scale_.begin(), kp= params.beginRows(); k<scale_.end(); ++k, kp+=2)
306 {
307 shape_ += params.row(kp);
308 scale_[k] = params.row(kp+1).mean();
309 }
310 shape_ /= scale_.size();
311 }
312};
313
317template<>
318struct ModelParameters<Clust::Gamma_ajk_b_>: public ParametersGammaBase
319{
328
332 ModelParameters(int nbCluster);
336 ModelParameters( ModelParameters const& param);
339
341 inline Real const& shape(int k, int j) const { return shape_[k][j];}
343 inline Real const& scale(int k, int j) const { return scale_;}
344
348 void resize(Range const& range);
349
351 void updateStatistics();
353 void setStatistics();
355 void releaseStatistics();
356
362 template<class Array>
364 {
365 scale_ = 0.;
366 for(int k=shape_.begin(), kp= params.beginRows(); k<shape_.end(); ++k, kp+=2)
367 {
368 shape_[k] = params.row(kp);
369 scale_ = params.row(kp+1).mean();
370 }
371 scale_ /= shape_.size();
372 }
373};
374
378template<>
379struct ModelParameters<Clust::Gamma_ajk_bj_>: public ParametersGammaBase
380{
389
393 ModelParameters(int nbCluster);
397 ModelParameters( ModelParameters const& param);
400
402 inline Real const& shape(int k, int j) const { return shape_[k][j];}
404 inline Real const& scale(int k, int j) const { return scale_[j];}
405
409 void resize(Range const& range);
410
412 void updateStatistics();
414 void setStatistics();
416 void releaseStatistics();
417
423 template<class Array>
425 {
426 scale_ = 0.;
427 for(int k=shape_.begin(), kp= params.beginRows(); k<shape_.end(); ++k, kp+=2)
428 {
429 shape_[k] = params.row(kp);
430 scale_ += params.row(kp+1);
431 }
432 scale_ /= shape_.size();
433 }
434};
435
439template<>
440struct ModelParameters<Clust::Gamma_ajk_bjk_>: public ParametersGammaBase
441{
450
454 ModelParameters(int nbCluster);
458 ModelParameters( ModelParameters const& param);
461
463 inline Real const& shape(int k, int j) const { return shape_[k][j];}
465 inline Real const& scale(int k, int j) const { return scale_[k][j];}
466
470 void resize(Range const& range);
471
473 void updateStatistics();
475 void setStatistics();
477 void releaseStatistics();
478
484 template<class Array>
486 {
487 for(int k=shape_.begin(), kp= params.beginRows(); k<shape_.end(); ++k, kp+=2)
488 {
489 shape_[k] = params.row(kp);
490 scale_[k] = params.row(kp+1);
491 }
492 }
493};
494
498template<>
499struct ModelParameters<Clust::Gamma_ajk_bk_>: public ParametersGammaBase
500{
509
513 ModelParameters(int nbCluster);
517 ModelParameters( ModelParameters const& param);
520
522 inline Real const& shape(int k, int j) const { return shape_[k][j];}
524 inline Real const& scale(int k, int j) const { return scale_[k];}
525
529 void resize(Range const& range);
530
532 void updateStatistics();
534 void setStatistics();
536 void releaseStatistics();
537
543 template<class Array>
545 {
546 for(int k=shape_.begin(), kp= params.beginRows(); k<shape_.end(); ++k, kp+=2)
547 {
548 shape_[k] = params.row(kp);
549 scale_[k] = params.row(kp+1).mean();
550 }
551 }
552};
553
557template<>
558struct ModelParameters<Clust::Gamma_ak_b_>: public ParametersGammaBase
559{
568
572 ModelParameters(int nbCluster);
576 ModelParameters( ModelParameters const& param);
579
581 inline Real const& shape(int k, int j) const { return shape_[k];}
583 inline Real const& scale(int k, int j) const { return scale_;}
584
588 void resize(Range const& range);
589
591 void updateStatistics();
593 void setStatistics();
595 void releaseStatistics();
596
602 template<class Array>
604 {
605 scale_ = 0.;
606 for(int k=shape_.begin(), kp= params.beginRows(); k<shape_.end(); ++k, kp+=2)
607 {
608 shape_[k] = params.row(kp).mean();
609 scale_ += params.row(kp+1).mean();
610 }
611 scale_ /= shape_.size();
612 }
613};
614
618template<>
619struct ModelParameters<Clust::Gamma_ak_bj_>: public ParametersGammaBase
620{
629
633 ModelParameters(int nbCluster);
637 ModelParameters( ModelParameters const& param);
640
642 inline Real const& shape(int k, int j) const { return shape_[k];}
644 inline Real const& scale(int k, int j) const { return scale_[j];}
645
649 void resize(Range const& range);
650
652 void updateStatistics();
654 void setStatistics();
656 void releaseStatistics();
657
663 template<class Array>
665 {
666 scale_ = 0.;
667 for(int k=shape_.begin(), kp= params.beginRows(); k<shape_.end(); ++k, kp+=2)
668 {
669 shape_[k] = params.row(kp).mean();
670 scale_ += params.row(kp+1);
671 }
672 scale_ /= shape_.size();
673 }
674};
675
679template<>
680struct ModelParameters<Clust::Gamma_ak_bjk_>: public ParametersGammaBase
681{
690
694 ModelParameters(int nbCluster);
698 ModelParameters( ModelParameters const& param);
701
703 inline Real const& shape(int k, int j) const { return shape_[k];}
705 inline Real const& scale(int k, int j) const { return scale_[k][j];}
706
710 void resize(Range const& range);
711
713 void updateStatistics();
715 void setStatistics();
717 void releaseStatistics();
718
724 template<class Array>
726 {
727 for(int k=shape_.begin(), kp= params.beginRows(); k<shape_.end(); ++k, kp+=2)
728 {
729 shape_[k] = params.row(kp).mean();
730 scale_[k] = params.row(kp+1);
731 }
732 }
733};
734
738template<>
739struct ModelParameters<Clust::Gamma_ak_bk_>: public ParametersGammaBase
740{
749
753 ModelParameters(int nbCluster);
757 ModelParameters( ModelParameters const& param);
760
762 inline Real const& shape(int k, int j) const { return shape_[k];}
764 inline Real const& scale(int k, int j) const { return scale_[k];}
765
769 void resize(Range const& range);
770
772 void updateStatistics();
774 void setStatistics();
776 void releaseStatistics();
777
783 template<class Array>
785 {
786 for(int k=shape_.begin(), kp= params.beginRows(); k<shape_.end(); ++k, kp+=2)
787 {
788 shape_[k] = params.row(kp).mean();
789 scale_[k] = params.row(kp+1).mean();
790 }
791 }
792};
793
794} // namespace STK
795
796#endif /* STK_GAMMAPARAMETERS_H */
In this file we define and implement the final class Array1D.
In this file we implement the final class CArrayPoint.
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.
Array1D< CPointX > scale_
scales of the variables
Array1D< Stat::Online< CPointX, Real > > stat_scale_
Array of the scale statistics.
Stat::Online< Real, Real > stat_shape_
shape statistics
void setParameters(ExprBase< Array > const &params)
Set the parameters of the mixture model.
void setParameters(ExprBase< Array > const &params)
Set the parameters of the mixture model.
Array1D< Real > scale_
scales of the variables
Stat::Online< Real, Real > stat_shape_
shape statistics
Array1D< Stat::Online< Real, Real > > stat_scale_
Array of the standard deviation statistics.
Array1D< CPointX > scale_
scales of the variables
void setParameters(ExprBase< Array > const &params)
Set the parameters of the mixture model.
Array1D< Stat::Online< CPointX, Real > > stat_scale_
Array of the scale statistics.
Stat::Online< CPointX, Real > stat_shape_
shape statistics
Array1D< Real > scale_
scales of the variables
void setParameters(ExprBase< Array > const &params)
Set the parameters of the mixture model.
Array1D< Stat::Online< Real, Real > > stat_scale_
Array of the standard deviation statistics.
Stat::Online< CPointX, Real > stat_shape_
shape statistics
void setParameters(ExprBase< Array > const &params)
Set the parameters of the mixture model.
Array1D< Stat::Online< CPointX, Real > > stat_shape_
Array of the mean statistics.
Stat::Online< Real, Real > stat_scale_
Array of the standard deviation statistics.
Array1D< CPointX > shape_
shapes of the variables
Array1D< CPointX > shape_
shapes of the variables
Stat::Online< CPointX, Real > stat_scale_
Array of the standard deviation statistics.
void setParameters(ExprBase< Array > const &params)
Set the parameters of the mixture model.
Array1D< Stat::Online< CPointX, Real > > stat_shape_
Array of the mean statistics.
Array1D< Stat::Online< CPointX, Real > > stat_shape_
Array of the mean statistics.
Array1D< CPointX > shape_
shapes of the variables
void setParameters(ExprBase< Array > const &params)
Set the parameters of the mixture model.
Array1D< CPointX > scale_
scales of the variables
Array1D< Stat::Online< CPointX, Real > > stat_scale_
Array of the standard deviation statistics.
void setParameters(ExprBase< Array > const &params)
Set the parameters of the mixture model.
Array1D< CPointX > shape_
shapes of the variables
Array1D< Stat::Online< Real, Real > > stat_scale_
Array of the standard deviation statistics.
Array1D< Stat::Online< CPointX, Real > > stat_shape_
Array of the mean statistics.
Array1D< Real > scale_
scales of the variables
Stat::Online< Real, Real > stat_scale_
Array of the standard deviation statistics.
Array1D< Real > shape_
shapes of the variables
Array1D< Stat::Online< Real, Real > > stat_shape_
Array of the mean statistics.
void setParameters(ExprBase< Array > const &params)
Set the parameters of the mixture model.
Array1D< Real > shape_
shapes of the variables
Stat::Online< CPointX, Real > stat_scale_
Array of the standard deviation statistics.
void setParameters(ExprBase< Array > const &params)
Set the parameters of the mixture model.
Array1D< Stat::Online< Real, Real > > stat_shape_
Array of the mean statistics.
Array1D< CPointX > scale_
scales of the variables
Array1D< Stat::Online< CPointX, Real > > stat_scale_
Array of the standard deviation statistics.
Array1D< Stat::Online< Real, Real > > stat_shape_
Array of the mean statistics.
Array1D< Real > shape_
shapes of the variables
void setParameters(ExprBase< Array > const &params)
Set the parameters of the mixture model.
Array1D< Real > scale_
scales of the variables
Array1D< Stat::Online< Real, Real > > stat_shape_
Array of the mean statistics.
Array1D< Stat::Online< Real, Real > > stat_scale_
Array of the standard deviation statistics.
Array1D< Real > shape_
shapes of the variables
void setParameters(ExprBase< Array > const &params)
Set the parameters of the mixture model.
struct storing the parameters of the mixture.
base class of the Gamma models Parameter Handler
Array1D< CPointX > meanLog_
log-means for each class
Array1D< CPointX > mean_
mean for each class
ParametersGammaBase & operator=(ParametersGammaBase const &other)
copy operator
Array1D< CPointX > variance_
variance for each class
void resize(Range const &range)