SHOGUN
v3.2.0
|
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 <shogun/features/Features.h> 00015 #include <shogun/mathematics/Math.h> 00016 #include <shogun/base/SGObject.h> 00017 00018 namespace shogun 00019 { 00020 class CFeatures; 00021 class CMath; 00041 class CDistribution : public CSGObject 00042 { 00043 public: 00045 CDistribution(); 00046 00048 virtual ~CDistribution(); 00049 00058 virtual bool train(CFeatures* data=NULL)=0; 00059 00066 virtual int32_t get_num_model_parameters()=0; 00067 00073 virtual int32_t get_num_relevant_model_parameters(); 00074 00081 virtual float64_t get_log_model_parameter(int32_t num_param)=0; 00082 00091 virtual float64_t get_log_derivative( 00092 int32_t num_param, int32_t num_example)=0; 00093 00101 virtual float64_t get_log_likelihood_example(int32_t num_example)=0; 00102 00107 virtual float64_t get_log_likelihood_sample(); 00108 00113 virtual SGVector<float64_t> get_log_likelihood(); 00114 00120 virtual float64_t get_model_parameter(int32_t num_param) 00121 { 00122 return exp(get_log_model_parameter(num_param)); 00123 } 00124 00131 virtual float64_t get_derivative( 00132 int32_t num_param, int32_t num_example) 00133 { 00134 return exp(get_log_derivative(num_param, num_example)); 00135 } 00136 00142 virtual float64_t get_likelihood_example(int32_t num_example) 00143 { 00144 return exp(get_log_likelihood_example(num_example)); 00145 } 00146 00151 virtual SGVector<float64_t> get_likelihood_for_all_examples(); 00152 00157 virtual void set_features(CFeatures* f) 00158 { 00159 SG_REF(f); 00160 SG_UNREF(features); 00161 features=f; 00162 } 00163 00168 virtual CFeatures* get_features() 00169 { 00170 SG_REF(features); 00171 return features; 00172 } 00173 00178 virtual void set_pseudo_count(float64_t pseudo) { pseudo_count=pseudo; } 00179 00184 virtual float64_t get_pseudo_count() { return pseudo_count; } 00185 00186 protected: 00188 CFeatures* features; 00190 float64_t pseudo_count; 00191 }; 00192 } 00193 #endif