00001 /*============================================================================= 00002 * Product : OpenPL 00003 * File : plLearnNdNormal.h 00004 * Author : Kamel Mekhnacha 00005 * Creation : Mon Oct 27 14:57:12 2003 00006 * 00007 *============================================================================= 00008 * (c) Copyright 2000, Centre National de la Recherche Scientifique, 00009 * all rights reserved 00010 *============================================================================= 00011 * 00012 *------------------------- Description --------------------------------------- 00013 * 00014 * 00015 *----------------------------------------------------------------------------- 00016 */ 00017 00018 #ifndef __plLearNdNormal_h_ 00019 #define __plLearNdNormal_h_ 00020 00021 #include <plLearn.h> 00022 #include <plFloatVector.h> 00023 #include <plFloatMatrix.h> 00024 #include <plNormal.h> 00025 00026 // A macro to get the size of the vector required to store the symmetric covariance matrix. 00027 #define VAR_MATRIX_SIZE(d) ( (d *(d + 1)/2) ) 00028 00029 // A macro to get a reference to the element (i, j) of the covariance matrix. ATTENTION: j > i. 00030 #define Sij(i, j) (_sij[ (i)*(2*_dimension-i+1)/2 + ((j) - (i))]) 00031 00033 class plLearnNdNormal :public plNonCndLearnObject 00034 { 00035 public: 00037 plLearnNdNormal(const plVariablesConjunction &vars); 00038 00040 plLearnNdNormal(const plVariablesConjunction &vars, const plFloatVector &init_mean, 00041 const plFloatMatrix &init_matrix, double init_weight = 1.0); 00042 00044 plLearnNdNormal(); 00045 00047 virtual ~plLearnNdNormal(){}; 00048 00050 void reset(); 00051 00054 void internal_addPoint(const plDataValues &point, double weight = 1.0); 00055 00056 void internal_addPointWithDef(const plDataValues &point, const vector <bool> &left_defined, double weight = 1.0); 00057 00058 00061 void getMean(plFloatVector &mean) const; 00062 00064 plFloatVector getMean() const; 00065 00068 void getCovariance(plFloatMatrix &covariance) const; 00069 00070 00072 plFloatMatrix getCovariance() const; 00073 00074 00078 void get_params(plValues ¶ms) const; 00079 00081 void get_actual_min_max(plFloatVector &min, plFloatVector &max) const; 00082 00084 plKernel get_distribution( const void *parameters = NULL ) const; 00085 00086 protected: 00087 unsigned int _dimension; 00088 vector <double> _s; 00089 //vector < vector <double> > _sij; 00090 vector <double> _sij; 00091 00092 00093 plFloatVector _init_mean; 00094 plFloatMatrix _init_covariance; 00095 double _init_weight; 00096 00097 bool _has_initialization; 00098 }; 00099 00100 00101 #endif