00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __plLearnKLaplace_h__
00021 #define __plLearnKLaplace_h__
00022
00023 #include <plLearn.h>
00024 #include <plLearnKHistogram.h>
00025
00027 class plLearnKLaplace : public plLearnKHistogram
00028 {
00029 public:
00030
00032 plLearnKLaplace():plLearnKHistogram(){}
00033
00035 plLearnKLaplace(const plVariablesConjunction &vars):plLearnKHistogram(vars){}
00036
00038 template <class arrayType>
00039 plLearnKLaplace(const plVariablesConjunction &vars, arrayType init_freq, double init_weight=1.0)
00040 :plLearnKHistogram(vars, init_freq, init_weight)
00041 {
00042 }
00043
00045 ~plLearnKLaplace(){}
00046
00048 void get_params(plValues ¶ms) const
00049 {
00050 double div = _total_weight + _freq.size();
00051 for(unsigned int i = 0; i < _freq.size(); i++){
00052 params[i] = (1.0 + _freq[i]) / div;
00053 }
00054 }
00055
00057 plKernel get_distribution( const void *parameters = NULL ) const
00058 {
00059 double div = _total_weight + _freq.size();
00060 vector <plProbValue> prob( _freq.size() );
00061 for(unsigned int i = 0; i < _freq.size(); i++){
00062 prob[i] = (1.0 + _freq[i]) / div;
00063 }
00064 return (plProbTable(_left_vars, prob) );
00065 }
00066
00068 void get_probability(vector <plProbValue> &table)const
00069 {
00070 table.resize( _freq.size() );
00071 double div = _total_weight + _freq.size();
00072 for(unsigned int i = 0; i < _freq.size(); i++) table[i] = (1.0 + _freq[i]) / div;
00073 }
00074
00077 void get_probability(plProbValue *table)const
00078 {
00079 double div = _total_weight + _freq.size();
00080 for(unsigned int i = 0; i < _freq.size(); i++) table[i] = (1.0 + _freq[i]) / div;
00081 }
00082
00083 };
00084
00085
00086 #endif