SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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>
24 
25 #include <shogun/lib/SGVector.h>
26 #include <shogun/lib/SGMatrix.h>
27 
28 namespace shogun
29 {
30 class CDotFeatures;
31 
34 {
41 };
42 
50 class CGaussian : public CDistribution
51 {
52  public:
54  CGaussian();
62  virtual ~CGaussian();
63 
65  void init();
66 
73  virtual bool train(CFeatures* data=NULL);
74 
79  virtual int32_t get_num_model_parameters();
80 
86  virtual float64_t get_log_model_parameter(int32_t num_param);
87 
95  int32_t num_param, int32_t num_example);
96 
104  virtual float64_t get_log_likelihood_example(int32_t num_example);
105 
113  virtual float64_t update_params_em(float64_t* alpha_k, int32_t len);
114 
121  {
122  return CMath::exp(compute_log_PDF(point));
123  }
124 
131 
136  virtual SGVector<float64_t> get_mean();
137 
142  virtual void set_mean(const SGVector<float64_t> mean);
143 
148  virtual SGMatrix<float64_t> get_cov();
149 
156  virtual void set_cov(SGMatrix<float64_t> cov);
157 
163  {
164  return m_cov_type;
165  }
166 
173  inline void set_cov_type(ECovType cov_type)
174  {
175  m_cov_type = cov_type;
176  }
177 
183  {
184  return m_d;
185  }
186 
191  void set_d(const SGVector<float64_t> d);
192 
198  {
199  return m_u;
200  }
201 
206  inline void set_u(SGMatrix<float64_t> u)
207  {
208  m_u = u;
209  }
210 
216 
221  static CGaussian* obtain_from_generic(CDistribution* distribution);
222 
224  virtual const char* get_name() const { return "Gaussian"; }
225 
226  private:
228  void register_params();
229 
234  void decompose_cov(SGMatrix<float64_t> cov);
235 
236  protected:
247 };
248 }
249 #endif //HAVE_LAPACK
250 #endif //_GAUSSIAN_H__
SGVector< float64_t > sample()
Definition: Gaussian.cpp:361
float64_t m_constant
Definition: Gaussian.h:238
void set_u(SGMatrix< float64_t > u)
Definition: Gaussian.h:206
Gaussian distribution interface.
Definition: Gaussian.h:50
ECovType get_cov_type()
Definition: Gaussian.h:162
virtual bool train(CFeatures *data=NULL)
Definition: Gaussian.cpp:65
virtual float64_t compute_log_PDF(SGVector< float64_t > point)
Definition: Gaussian.cpp:221
Base class Distribution from which all methods implementing a distribution are derived.
Definition: Distribution.h:44
ECovType m_cov_type
Definition: Gaussian.h:246
full covariance
Definition: Gaussian.h:36
spherical covariance
Definition: Gaussian.h:40
virtual float64_t compute_PDF(SGVector< float64_t > point)
Definition: Gaussian.h:120
virtual float64_t update_params_em(float64_t *alpha_k, int32_t len)
Definition: Gaussian.cpp:117
SGMatrix< float64_t > m_u
Definition: Gaussian.h:242
virtual SGVector< float64_t > get_mean()
Definition: Gaussian.cpp:260
virtual float64_t get_log_model_parameter(int32_t num_param)
Definition: Gaussian.cpp:97
SGMatrix< float64_t > get_u()
Definition: Gaussian.h:197
static CGaussian * obtain_from_generic(CDistribution *distribution)
Definition: Gaussian.cpp:412
virtual void set_cov(SGMatrix< float64_t > cov)
Definition: Gaussian.cpp:273
double float64_t
Definition: common.h:50
ECovType
Definition: Gaussian.h:33
SGVector< float64_t > m_mean
Definition: Gaussian.h:244
virtual SGMatrix< float64_t > get_cov()
Definition: Gaussian.cpp:287
void set_cov_type(ECovType cov_type)
Definition: Gaussian.h:173
virtual ~CGaussian()
Definition: Gaussian.cpp:61
diagonal covariance
Definition: Gaussian.h:38
virtual float64_t get_log_likelihood_example(int32_t num_example)
Definition: Gaussian.cpp:109
virtual const char * get_name() const
Definition: Gaussian.h:224
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:182
virtual void set_mean(const SGVector< float64_t > mean)
Definition: Gaussian.cpp:265
virtual int32_t get_num_model_parameters()
Definition: Gaussian.cpp:83
virtual float64_t get_log_derivative(int32_t num_param, int32_t num_example)
Definition: Gaussian.cpp:103
void set_d(const SGVector< float64_t > d)
Definition: Gaussian.cpp:281
SGVector< float64_t > m_d
Definition: Gaussian.h:240

SHOGUN Machine Learning Toolbox - Documentation