Distribution.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 1999-2009 Soeren Sonnenburg
00008  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #ifndef _DISTRIBUTION_H___
00012 #define _DISTRIBUTION_H___
00013 
00014 #include "features/Features.h"
00015 #include "lib/Mathematics.h"
00016 #include "base/SGObject.h"
00017 
00037 class CDistribution : public CSGObject
00038 {
00039     public:
00041         CDistribution();
00042         virtual ~CDistribution();
00043 
00050         virtual bool train()=0;
00051 
00058         virtual int32_t get_num_model_parameters()=0;
00059 
00065         virtual int32_t get_num_relevant_model_parameters();
00066 
00073         virtual float64_t get_log_model_parameter(int32_t num_param)=0;
00074 
00083         virtual float64_t get_log_derivative(
00084             int32_t num_param, int32_t num_example)=0;
00085 
00093         virtual float64_t get_log_likelihood_example(int32_t num_example)=0;
00094 
00099         virtual float64_t get_log_likelihood_sample();
00100 
00106         virtual void get_log_likelihood(float64_t** dst, int32_t *num);
00107 
00113         virtual inline float64_t get_model_parameter(int32_t num_param)
00114         {
00115             return exp(get_log_model_parameter(num_param));
00116         }
00117 
00124         virtual inline float64_t get_derivative(
00125             int32_t num_param, int32_t num_example)
00126         {
00127             return exp(get_log_derivative(num_param, num_example));
00128         }
00129 
00135         virtual inline float64_t get_likelihood_example(int32_t num_example)
00136         {
00137             return exp(get_log_likelihood_example(num_example));
00138         }
00139 
00144         virtual inline void set_features(CFeatures* f) { features=f; }
00145 
00150         virtual inline CFeatures* get_features() { return features; }
00151 
00156         virtual inline void set_pseudo_count(float64_t pseudo) { pseudo_count=pseudo; }
00157 
00162         virtual inline float64_t get_pseudo_count() { return pseudo_count; }
00163 
00164     protected:
00166         CFeatures* features;
00168         float64_t pseudo_count;
00169 };
00170 #endif
00171 

SHOGUN Machine Learning Toolbox - Documentation