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  * Written (W) 2014 Parijat Mazumdar
9  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10  */
11 
12 #ifndef _DISTRIBUTION_H___
13 #define _DISTRIBUTION_H___
14 
15 #include <shogun/lib/config.h>
16 
19 #include <shogun/base/SGObject.h>
20 
21 namespace shogun
22 {
23 class CFeatures;
24 class CMath;
44 class CDistribution : public CSGObject
45 {
46  public:
48  CDistribution();
49 
51  virtual ~CDistribution();
52 
61  virtual bool train(CFeatures* data=NULL)=0;
62 
69  virtual int32_t get_num_model_parameters()=0;
70 
76  virtual int32_t get_num_relevant_model_parameters();
77 
84  virtual float64_t get_log_model_parameter(int32_t num_param)=0;
85 
95  int32_t num_param, int32_t num_example)=0;
96 
104  virtual float64_t get_log_likelihood_example(int32_t num_example)=0;
105 
111 
117 
123  virtual float64_t get_model_parameter(int32_t num_param)
124  {
125  return exp(get_log_model_parameter(num_param));
126  }
127 
135  int32_t num_param, int32_t num_example)
136  {
137  return exp(get_log_derivative(num_param, num_example));
138  }
139 
145  virtual float64_t get_likelihood_example(int32_t num_example)
146  {
147  return exp(get_log_likelihood_example(num_example));
148  }
149 
155 
160  virtual void set_features(CFeatures* f)
161  {
163  features=f;
164  SG_REF(features);
165  }
166 
172  {
173  SG_REF(features);
174  return features;
175  }
176 
181  virtual void set_pseudo_count(float64_t pseudo) { pseudo_count=pseudo; }
182 
188 
198  virtual float64_t update_params_em(float64_t* alpha_k, int32_t len);
199 
205  static CDistribution* obtain_from_generic(CSGObject* object);
206 
207  protected:
212 };
213 }
214 #endif

SHOGUN Machine Learning Toolbox - Documentation