SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Distribution.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) 1999-2009 Soeren Sonnenburg
8  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
11 #ifndef _DISTRIBUTION_H___
12 #define _DISTRIBUTION_H___
13 
16 #include <shogun/base/SGObject.h>
17 
18 namespace shogun
19 {
20 class CFeatures;
21 class CMath;
41 class CDistribution : public CSGObject
42 {
43  public:
45  CDistribution();
46  virtual ~CDistribution();
47 
56  virtual bool train(CFeatures* data=NULL)=0;
57 
64  virtual int32_t get_num_model_parameters()=0;
65 
71  virtual int32_t get_num_relevant_model_parameters();
72 
79  virtual float64_t get_log_model_parameter(int32_t num_param)=0;
80 
90  int32_t num_param, int32_t num_example)=0;
91 
99  virtual float64_t get_log_likelihood_example(int32_t num_example)=0;
100 
106 
112 
118  virtual inline float64_t get_model_parameter(int32_t num_param)
119  {
120  return exp(get_log_model_parameter(num_param));
121  }
122 
129  virtual inline float64_t get_derivative(
130  int32_t num_param, int32_t num_example)
131  {
132  return exp(get_log_derivative(num_param, num_example));
133  }
134 
140  virtual inline float64_t get_likelihood_example(int32_t num_example)
141  {
142  return exp(get_log_likelihood_example(num_example));
143  }
144 
149  virtual inline void set_features(CFeatures* f)
150  {
152  SG_REF(f);
153  features=f;
154  }
155 
160  virtual inline CFeatures* get_features()
161  {
162  SG_REF(features);
163  return features;
164  }
165 
170  virtual inline void set_pseudo_count(float64_t pseudo) { pseudo_count=pseudo; }
171 
176  virtual inline float64_t get_pseudo_count() { return pseudo_count; }
177 
178  protected:
183 };
184 }
185 #endif

SHOGUN Machine Learning Toolbox - Documentation