Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members

plLearnKLidstone.h

00001 /*==============================================================================
00002  * Product        : OpenPL 
00003  * File           : plLearnKLidstone.h
00004  * Author         : Manuel Yguel
00005  * Creation       : Mon Nov 10 08:52:09 2003
00006  *
00007  *==============================================================================
00008  *     (c) Copyright 2000, Centre National de la Recherche Scientifique,
00009  *                              all rights reserved
00010  *==============================================================================
00011  *
00012  *------------------------- Description ----------------------------------------
00013  *   Learning n dimensionnal Lidstone's distribution with KNOWN variables 
00014  *   definition sets.
00015  *   
00016  *------------------------------------------------------------------------------
00017  */
00018 
00019 
00020 #ifndef __plLearnKLidstone_h__
00021 #define __plLearnKLidstone_h__
00022 
00023 #include <plLearn.h>
00024 #include <plLearnKHistogram.h>
00025 
00027 class plLearnKLidstone : public plLearnKHistogram
00028 {
00029 protected :
00030   double _alpha; 
00031 public:
00032  
00034   plLearnKLidstone():plLearnKHistogram(){}
00035     
00037   plLearnKLidstone(const plVariablesConjunction &vars, double alpha= 1.0)
00038     : plLearnKHistogram( vars ), _alpha( alpha )
00039   {}
00040     
00042   ~plLearnKLidstone(){}
00043     
00044 
00046   inline void setLidstoneParam( double alpha )
00047     {
00048       _alpha = alpha;
00049     }
00050 
00051 
00053   void get_params(plValues &params) const
00054   {
00055     double div = _total_weight + _alpha*_freq.size();
00056     for(unsigned int i = 0; i < _freq.size(); i++){
00057       params[i] = (_alpha + _freq[i]) / div;
00058     }
00059   }
00060   
00065   plKernel get_distribution( const void *parameters = NULL ) const
00066   {
00067     double alpha = _alpha;
00068     if( NULL != parameters )
00069       {
00070         double *ptr_alpha = (double *)parameters;
00071         alpha = *ptr_alpha;
00072       }
00073 
00074     double div = _total_weight + alpha*_freq.size();
00075     vector <plProbValue> prob( _freq.size() );
00076     for(unsigned int i = 0; i < _freq.size(); i++){
00077       prob[i] = (alpha + _freq[i]) / div;
00078     }
00079     return ( plProbTable(_left_vars, prob) );
00080   }
00081     
00083   void get_probability(vector <plProbValue> &table)const
00084   {
00085     table.resize( _freq.size() );
00086     double div = _total_weight + _alpha*_freq.size();
00087     for(unsigned int i = 0; i < _freq.size(); i++) table[i] = (_alpha + _freq[i]) / div;
00088   }
00089 
00092   void get_probability(plProbValue *table)const
00093   {
00094     double div = _total_weight + _alpha*_freq.size();
00095     for(unsigned int i = 0; i < _freq.size(); i++) table[i] = (_alpha + _freq[i]) / div;
00096   }
00097 
00098 };
00099 
00100 
00101 #endif

Generated on Fri Apr 1 10:58:13 2005 for ProBT by  doxygen 1.4.1