SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 
206 
207  protected:
212 };
213 }
214 #endif
virtual void set_features(CFeatures *f)
Definition: Distribution.h:160
virtual float64_t get_model_parameter(int32_t num_param)
Definition: Distribution.h:123
static CDistribution * obtain_from_generic(CSGObject *object)
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:181
Base class Distribution from which all methods implementing a distribution are derived.
Definition: Distribution.h:44
#define SG_REF(x)
Definition: SGObject.h:51
virtual float64_t get_derivative(int32_t num_param, int32_t num_example)
Definition: Distribution.h:134
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:112
double float64_t
Definition: common.h:50
virtual CFeatures * get_features()
Definition: Distribution.h:171
virtual float64_t update_params_em(float64_t *alpha_k, int32_t len)
virtual float64_t get_likelihood_example(int32_t num_example)
Definition: Distribution.h:145
virtual float64_t get_pseudo_count()
Definition: Distribution.h:187
virtual SGVector< float64_t > get_likelihood_for_all_examples()
#define SG_UNREF(x)
Definition: SGObject.h:52
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
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