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-2008 Soeren Sonnenburg
00008  * Copyright (C) 1999-2008 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 
00019 class CDistribution : public CSGObject
00020 {
00021     public:
00023         CDistribution();
00024         virtual ~CDistribution();
00025 
00032         virtual bool train()=0;
00033 
00040         virtual INT get_num_model_parameters()=0;
00041 
00047         virtual INT get_num_relevant_model_parameters();
00048 
00055         virtual DREAL get_log_model_parameter(INT num_param)=0;
00056 
00065         virtual DREAL get_log_derivative(INT num_param, INT num_example)=0;
00066 
00074         virtual DREAL get_log_likelihood_example(INT num_example)=0;
00075 
00080         virtual DREAL get_log_likelihood_sample();
00081 
00087         virtual void get_log_likelihood(DREAL** dst, INT *num);
00088 
00094         virtual inline DREAL get_model_parameter(INT num_param)
00095         {
00096             return exp(get_log_model_parameter(num_param));
00097         }
00098 
00105         virtual inline DREAL get_derivative(INT num_param, INT num_example)
00106         {
00107             return exp(get_log_derivative(num_param, num_example));
00108         }
00109 
00115         virtual inline DREAL get_likelihood_example(INT num_example)
00116         {
00117             return exp(get_log_likelihood_example(num_example));
00118         }
00119 
00124         virtual inline void set_features(CFeatures* f) { features=f; }
00125 
00130         virtual inline CFeatures* get_features() { return features; }
00131 
00136         virtual inline void set_pseudo_count(DREAL pseudo) { pseudo_count=pseudo; }
00137 
00142         virtual inline DREAL get_pseudo_count() { return pseudo_count; }
00143 
00144     protected:
00146         CFeatures* features;
00148         DREAL pseudo_count;
00149 };
00150 #endif
00151 

SHOGUN Machine Learning Toolbox - Documentation