SHOGUN  3.2.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 
14 #include <shogun/lib/config.h>
15 
18 #include <shogun/base/SGObject.h>
19 
20 namespace shogun
21 {
22 class CFeatures;
23 class CMath;
43 class CDistribution : public CSGObject
44 {
45  public:
47  CDistribution();
48 
50  virtual ~CDistribution();
51 
60  virtual bool train(CFeatures* data=NULL)=0;
61 
68  virtual int32_t get_num_model_parameters()=0;
69 
75  virtual int32_t get_num_relevant_model_parameters();
76 
83  virtual float64_t get_log_model_parameter(int32_t num_param)=0;
84 
94  int32_t num_param, int32_t num_example)=0;
95 
103  virtual float64_t get_log_likelihood_example(int32_t num_example)=0;
104 
110 
116 
122  virtual float64_t get_model_parameter(int32_t num_param)
123  {
124  return exp(get_log_model_parameter(num_param));
125  }
126 
134  int32_t num_param, int32_t num_example)
135  {
136  return exp(get_log_derivative(num_param, num_example));
137  }
138 
144  virtual float64_t get_likelihood_example(int32_t num_example)
145  {
146  return exp(get_log_likelihood_example(num_example));
147  }
148 
154 
159  virtual void set_features(CFeatures* f)
160  {
161  SG_REF(f);
163  features=f;
164  }
165 
171  {
172  SG_REF(features);
173  return features;
174  }
175 
180  virtual void set_pseudo_count(float64_t pseudo) { pseudo_count=pseudo; }
181 
187 
188  protected:
193 };
194 }
195 #endif

SHOGUN Machine Learning Toolbox - Documentation