SHOGUN  v3.0.1
 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 float64_t get_model_parameter(int32_t num_param)
119  {
120  return exp(get_log_model_parameter(num_param));
121  }
122 
130  int32_t num_param, int32_t num_example)
131  {
132  return exp(get_log_derivative(num_param, num_example));
133  }
134 
140  virtual float64_t get_likelihood_example(int32_t num_example)
141  {
142  return exp(get_log_likelihood_example(num_example));
143  }
144 
150 
155  virtual void set_features(CFeatures* f)
156  {
157  SG_REF(f);
159  features=f;
160  }
161 
167  {
168  SG_REF(features);
169  return features;
170  }
171 
176  virtual void set_pseudo_count(float64_t pseudo) { pseudo_count=pseudo; }
177 
183 
184  protected:
189 };
190 }
191 #endif
virtual void set_features(CFeatures *f)
Definition: Distribution.h:155
virtual float64_t get_model_parameter(int32_t num_param)
Definition: Distribution.h:118
virtual SGVector< float64_t > get_log_likelihood()
virtual int32_t get_num_relevant_model_parameters()
virtual void set_pseudo_count(float64_t pseudo)
Definition: Distribution.h:176
Base class Distribution from which all methods implementing a distribution are derived.
Definition: Distribution.h:41
#define SG_REF(x)
Definition: SGObject.h:53
virtual float64_t get_derivative(int32_t num_param, int32_t num_example)
Definition: Distribution.h:129
virtual float64_t get_log_model_parameter(int32_t num_param)=0
virtual bool train(CFeatures *data=NULL)=0
virtual float64_t get_log_likelihood_sample()
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:114
double float64_t
Definition: common.h:48
virtual CFeatures * get_features()
Definition: Distribution.h:166
virtual float64_t get_likelihood_example(int32_t num_example)
Definition: Distribution.h:140
virtual float64_t get_pseudo_count()
Definition: Distribution.h:182
virtual SGVector< float64_t > get_likelihood_for_all_examples()
#define SG_UNREF(x)
Definition: SGObject.h:54
The class Features is the base class of all feature objects.
Definition: Features.h:62
virtual float64_t get_log_likelihood_example(int32_t num_example)=0
virtual float64_t get_log_derivative(int32_t num_param, int32_t num_example)=0
virtual int32_t get_num_model_parameters()=0

SHOGUN Machine Learning Toolbox - Documentation