SHOGUN  5.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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 
17 #ifdef HAVE_LAPACK
18 
21 #include <shogun/lib/common.h>
23 
24 #include <shogun/lib/SGVector.h>
25 #include <shogun/lib/SGMatrix.h>
26 
27 namespace shogun
28 {
29 class CDotFeatures;
30 
33 {
40 };
41 
49 class CGaussian : public CDistribution
50 {
51  public:
53  CGaussian();
61  virtual ~CGaussian();
62 
64  void init();
65 
72  virtual bool train(CFeatures* data=NULL);
73 
78  virtual int32_t get_num_model_parameters();
79 
85  virtual float64_t get_log_model_parameter(int32_t num_param);
86 
94  int32_t num_param, int32_t num_example);
95 
103  virtual float64_t get_log_likelihood_example(int32_t num_example);
104 
112  virtual float64_t update_params_em(float64_t* alpha_k, int32_t len);
113 
120  {
121  return CMath::exp(compute_log_PDF(point));
122  }
123 
130 
135  virtual SGVector<float64_t> get_mean();
136 
141  virtual void set_mean(const SGVector<float64_t> mean);
142 
147  virtual SGMatrix<float64_t> get_cov();
148 
155  virtual void set_cov(SGMatrix<float64_t> cov);
156 
162  {
163  return m_cov_type;
164  }
165 
172  inline void set_cov_type(ECovType cov_type)
173  {
174  m_cov_type = cov_type;
175  }
176 
182  {
183  return m_d;
184  }
185 
190  void set_d(const SGVector<float64_t> d);
191 
197  {
198  return m_u;
199  }
200 
205  inline void set_u(SGMatrix<float64_t> u)
206  {
207  m_u = u;
208  }
209 
215 
220  static CGaussian* obtain_from_generic(CDistribution* distribution);
221 
223  virtual const char* get_name() const { return "Gaussian"; }
224 
225  private:
227  void register_params();
228 
233  void decompose_cov(SGMatrix<float64_t> cov);
234 
235  protected:
246 };
247 }
248 #endif //HAVE_LAPACK
249 #endif //_GAUSSIAN_H__
SGVector< float64_t > sample()
Definition: Gaussian.cpp:362
float64_t m_constant
Definition: Gaussian.h:237
void set_u(SGMatrix< float64_t > u)
Definition: Gaussian.h:205
Gaussian distribution interface.
Definition: Gaussian.h:49
ECovType get_cov_type()
Definition: Gaussian.h:161
virtual bool train(CFeatures *data=NULL)
Definition: Gaussian.cpp:66
virtual float64_t compute_log_PDF(SGVector< float64_t > point)
Definition: Gaussian.cpp:222
Base class Distribution from which all methods implementing a distribution are derived.
Definition: Distribution.h:44
ECovType m_cov_type
Definition: Gaussian.h:245
full covariance
Definition: Gaussian.h:35
spherical covariance
Definition: Gaussian.h:39
virtual float64_t compute_PDF(SGVector< float64_t > point)
Definition: Gaussian.h:119
virtual float64_t update_params_em(float64_t *alpha_k, int32_t len)
Definition: Gaussian.cpp:118
SGMatrix< float64_t > m_u
Definition: Gaussian.h:241
virtual SGVector< float64_t > get_mean()
Definition: Gaussian.cpp:261
virtual float64_t get_log_model_parameter(int32_t num_param)
Definition: Gaussian.cpp:98
SGMatrix< float64_t > get_u()
Definition: Gaussian.h:196
static CGaussian * obtain_from_generic(CDistribution *distribution)
Definition: Gaussian.cpp:413
virtual void set_cov(SGMatrix< float64_t > cov)
Definition: Gaussian.cpp:274
double float64_t
Definition: common.h:50
ECovType
Definition: Gaussian.h:32
SGVector< float64_t > m_mean
Definition: Gaussian.h:243
virtual SGMatrix< float64_t > get_cov()
Definition: Gaussian.cpp:288
void set_cov_type(ECovType cov_type)
Definition: Gaussian.h:172
virtual ~CGaussian()
Definition: Gaussian.cpp:62
diagonal covariance
Definition: Gaussian.h:37
virtual float64_t get_log_likelihood_example(int32_t num_example)
Definition: Gaussian.cpp:110
virtual const char * get_name() const
Definition: Gaussian.h:223
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:68
static float64_t exp(float64_t x)
Definition: Math.h:621
SGVector< float64_t > get_d()
Definition: Gaussian.h:181
virtual void set_mean(const SGVector< float64_t > mean)
Definition: Gaussian.cpp:266
virtual int32_t get_num_model_parameters()
Definition: Gaussian.cpp:84
virtual float64_t get_log_derivative(int32_t num_param, int32_t num_example)
Definition: Gaussian.cpp:104
void set_d(const SGVector< float64_t > d)
Definition: Gaussian.cpp:282
SGVector< float64_t > m_d
Definition: Gaussian.h:239

SHOGUN Machine Learning Toolbox - Documentation