yat  0.21pre
GaussianMixture.h
1 #ifndef _theplu_yat_statistics_gaussian_mixture_
2 #define _theplu_yat_statistics_gaussian_mixture_
3 
4 // $Id: GaussianMixture.h 4207 2022-08-26 04:36:28Z peter $
5 
6 /*
7  Copyright (C) 2017, 2022 Peter Johansson
8 
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10 
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15 
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #include <yat/utility/Vector.h>
26 
27 #include <cstddef>
28 #include <vector>
29 
30 namespace theplu {
31 namespace yat {
32 namespace utility {
33  class Matrix;
34 }
35 namespace statistics {
36 
46  {
47  public:
51  void add(double x, unsigned long int n=1);
52 
56  double alpha(size_t i) const;
57 
61  double cdf_P(double x) const;
62 
66  void clear(void);
67 
73  void fit(size_t n);
74 
81  void fit(const utility::Vector& alpha, const utility::Vector& mean,
82  const utility::Vector& sigma);
83 
87  double mean(void) const;
88 
92  double mean(size_t i) const;
93 
97  double pdf(double x) const;
98 
102  double std(size_t i) const;
103 
104  private:
105  struct data_type
106  {
107  data_type(double x, unsigned long int n);
108  double x;
109  unsigned long int n;
110  };
111  std::vector<data_type> data_;
112 
113  utility::Vector alpha_;
114  utility::Vector mean_;
115  utility::Vector sigma_;
116 
117  void calculate_posterior(utility::Matrix& h) const;
118  void fit(void);
119  void update_model(const utility::Matrix& h);
120  };
121 
122 }}} // of namespace statistics, yat, and theplu
123 
124 #endif
The Department of Theoretical Physics namespace as we define it.
Data modelled as mixture of Gaussian distributions.
Definition: GaussianMixture.h:45
This is the yat interface to GSL vector.
Definition: Vector.h:59
void add(double x, unsigned long int n=1)
void fit(size_t n)
fit the model
void clear(void)
Clear all data.
Interface to GSL matrix.
Definition: Matrix.h:104

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14