yat  0.21pre
PoissonMixture.h
1 #ifndef theplu_yat_statistics_poisson_mixture_
2 #define theplu_yat_statistics_poisson_mixture_
3 
4 // $Id: PoissonMixture.h 4181 2022-06-14 23:45:33Z peter $
5 
6 /*
7  Copyright (C) 2022 Peter Johansson
8 
9  This file is part of the yat library, https://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 <https://www.gnu.org/licenses/>.
23 */
24 
25 #include <yat/utility/Vector.h>
26 
27 #include <map>
28 
29 namespace theplu {
30 namespace yat {
31  namespace utility {
32  class Matrix;
33  }
34 namespace statistics {
35 
45  {
46  public:
50  void add(unsigned long int k, unsigned long int n=1);
51 
55  void clear(void);
56 
61  void fit(size_t n);
62 
67  void fit(const yat::utility::VectorBase& m,
69 
77  double logL(void);
78 
82  double mean(size_t i) const;
83 
87  double tau(size_t i) const;
88  private:
89  std::map<unsigned long int, unsigned long int> count_;
92 
93  // guess the parameters using a Gaussian mixture model
94  void init_fit(size_t n);
95  bool expectation_step(yat::utility::Matrix& H) const;
96 
97  // Find the optimal parameters
98  void optimize(void);
99 
100  // return true if sum squared difference is > 1e-9
101  bool optimize_tau(const yat::utility::Matrix& H);
102  // return true if sum squared difference is > 1e-9
103  bool optimize_m(const yat::utility::Matrix& H);
104  };
105 
106 }}}
107 #endif
The Department of Theoretical Physics namespace as we define it.
Infer Poissonian mixed model.
Definition: PoissonMixture.h:44
void add(unsigned long int k, unsigned long int n=1)
This is the yat interface to GSL vector.
Definition: Vector.h:59
This is the yat interface to GSL vector.
Definition: VectorBase.h:55
void clear(void)
Remove all data points.
Interface to GSL matrix.
Definition: Matrix.h:104

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