00001 #ifndef __SeparateGaussianClassifier__ 00002 #define __SeparateGaussianClassifier__ 00003 00022 #include "ASeparateFeatureClassifier.hpp" 00023 00024 class SeparateGaussianClassifier : public ASeparateFeatureClassifier 00025 { 00026 protected: 00027 00028 RealVector* meanValue; 00029 RealVector* sigma; 00030 00031 double root2nPI; // root(2*PI)^nFeature 00032 double logroot2nPI; 00033 00034 double sumLogSigma; 00035 double productSigma; 00036 00037 00038 protected: 00039 00040 virtual double reducedValue(int i, double featurei) 00041 { return ((featurei-meanValue->get0(i))/(sigma->get0(i)+1e-12)); } 00042 00043 public: 00044 00045 00046 SeparateGaussianClassifier(int n); 00047 virtual ~SeparateGaussianClassifier(){delete meanValue; delete sigma;} 00048 00049 virtual double distance2(RealVector& featureVector); 00050 00051 // learning 00052 virtual void start(); 00053 00054 // probability 00055 virtual double P(RealVector& featureVector); 00056 00057 // likelihood 00058 virtual double L(RealVector& featureVector); 00059 00060 virtual void output(FILE* file); 00061 00062 virtual void output() 00063 { 00064 printf("A Separate Gaussian Classifier(%d)", nFeatures); 00065 } 00066 }; 00067 00068 #endif