SHOGUN  6.1.3
Gaussian.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2011 Alesis Novik
8  * Written (W) 2014 Parijat Mazumdar
9  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
10  */
11 
12 #ifndef _GAUSSIAN_H__
13 #define _GAUSSIAN_H__
14 
15 #include <shogun/lib/config.h>
16 
19 #include <shogun/lib/common.h>
21 
22 #include <shogun/lib/SGVector.h>
23 #include <shogun/lib/SGMatrix.h>
24 
25 namespace shogun
26 {
27 class CDotFeatures;
28 
31 {
38 };
39 
47 class CGaussian : public CDistribution
48 {
49  public:
51  CGaussian();
59  virtual ~CGaussian();
60 
62  void init();
63 
70  virtual bool train(CFeatures* data=NULL);
71 
76  virtual int32_t get_num_model_parameters();
77 
83  virtual float64_t get_log_model_parameter(int32_t num_param);
84 
92  int32_t num_param, int32_t num_example);
93 
101  virtual float64_t get_log_likelihood_example(int32_t num_example);
102 
110  virtual float64_t update_params_em(float64_t* alpha_k, int32_t len);
111 
118  {
119  return CMath::exp(compute_log_PDF(point));
120  }
121 
128 
133  virtual SGVector<float64_t> get_mean();
134 
139  virtual void set_mean(const SGVector<float64_t> mean);
140 
145  virtual SGMatrix<float64_t> get_cov();
146 
153  virtual void set_cov(SGMatrix<float64_t> cov);
154 
160  {
161  return m_cov_type;
162  }
163 
170  inline void set_cov_type(ECovType cov_type)
171  {
172  m_cov_type = cov_type;
173  }
174 
180  {
181  return m_d;
182  }
183 
188  void set_d(const SGVector<float64_t> d);
189 
195  {
196  return m_u;
197  }
198 
203  inline void set_u(SGMatrix<float64_t> u)
204  {
205  m_u = u;
206  }
207 
213 
218  static CGaussian* obtain_from_generic(CDistribution* distribution);
219 
221  virtual const char* get_name() const { return "Gaussian"; }
222 
223  private:
225  void register_params();
226 
231  void decompose_cov(SGMatrix<float64_t> cov);
232 
233  protected:
244 };
245 }
246 #endif //_GAUSSIAN_H__
SGVector< float64_t > sample()
Definition: Gaussian.cpp:391
float64_t m_constant
Definition: Gaussian.h:235
void set_u(SGMatrix< float64_t > u)
Definition: Gaussian.h:203
Gaussian distribution interface.
Definition: Gaussian.h:47
ECovType get_cov_type()
Definition: Gaussian.h:159
virtual bool train(CFeatures *data=NULL)
Definition: Gaussian.cpp:68
virtual float64_t compute_log_PDF(SGVector< float64_t > point)
Definition: Gaussian.cpp:237
Base class Distribution from which all methods implementing a distribution are derived.
Definition: Distribution.h:44
std::enable_if<!std::is_same< T, complex128_t >::value, float64_t >::type mean(const Container< T > &a)
ECovType m_cov_type
Definition: Gaussian.h:243
full covariance
Definition: Gaussian.h:33
spherical covariance
Definition: Gaussian.h:37
virtual float64_t compute_PDF(SGVector< float64_t > point)
Definition: Gaussian.h:117
virtual float64_t update_params_em(float64_t *alpha_k, int32_t len)
Definition: Gaussian.cpp:120
SGMatrix< float64_t > m_u
Definition: Gaussian.h:239
virtual SGVector< float64_t > get_mean()
Definition: Gaussian.cpp:276
virtual float64_t get_log_model_parameter(int32_t num_param)
Definition: Gaussian.cpp:100
SGMatrix< float64_t > get_u()
Definition: Gaussian.h:194
static CGaussian * obtain_from_generic(CDistribution *distribution)
Definition: Gaussian.cpp:449
virtual void set_cov(SGMatrix< float64_t > cov)
Definition: Gaussian.cpp:289
double float64_t
Definition: common.h:60
ECovType
Definition: Gaussian.h:30
SGVector< float64_t > m_mean
Definition: Gaussian.h:241
virtual SGMatrix< float64_t > get_cov()
Definition: Gaussian.cpp:303
void set_cov_type(ECovType cov_type)
Definition: Gaussian.h:170
virtual ~CGaussian()
Definition: Gaussian.cpp:64
diagonal covariance
Definition: Gaussian.h:35
virtual float64_t get_log_likelihood_example(int32_t num_example)
Definition: Gaussian.cpp:112
virtual const char * get_name() const
Definition: Gaussian.h:221
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:69
static float64_t exp(float64_t x)
Definition: Math.h:551
SGVector< float64_t > get_d()
Definition: Gaussian.h:179
virtual void set_mean(const SGVector< float64_t > mean)
Definition: Gaussian.cpp:281
virtual int32_t get_num_model_parameters()
Definition: Gaussian.cpp:86
virtual float64_t get_log_derivative(int32_t num_param, int32_t num_example)
Definition: Gaussian.cpp:106
void set_d(const SGVector< float64_t > d)
Definition: Gaussian.cpp:297
SGVector< float64_t > m_d
Definition: Gaussian.h:237

SHOGUN Machine Learning Toolbox - Documentation