00001 #ifndef _theplu_yat_statistics_sam_score_
00002 #define _theplu_yat_statistics_sam_score_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "Score.h"
00026
00027 #include <cmath>
00028
00029 namespace theplu {
00030 namespace yat {
00031 namespace utility {
00032 class VectorBase;
00033 }
00034 namespace classifier {
00035 class DataLookWeighted1D;
00036 }
00037 namespace statistics {
00038
00050 class SAMScore : public Score
00051 {
00052
00053 public:
00058 SAMScore(const double s0, bool absolute=true);
00059
00069 double score(const classifier::Target& target,
00070 const utility::VectorBase& value) const;
00071
00083 double score(const classifier::Target& target,
00084 const classifier::DataLookupWeighted1D& value) const;
00085
00097 double score(const classifier::Target& target,
00098 const utility::VectorBase& value,
00099 const utility::VectorBase& weight) const;
00100 private:
00101 double s0_;
00102
00103 template<class T>
00104 double score(const T& positive, const T& negative) const
00105 {
00106 if(positive.n()+negative.n()<=2)
00107 return 0;
00108 double diff = positive.mean() - negative.mean();
00109 double s2 = ( (1.0/positive.n()+1.0/negative.n()) *
00110 (positive.sum_xx_centered()+negative.sum_xx_centered()) /
00111 (positive.n()+negative.n()-2) );
00112 if (diff<0 && absolute_)
00113 return -diff/(sqrt(s2)+s0_);
00114 return diff/(sqrt(s2)+s0_);
00115 }
00116 };
00117
00118 }}}
00119
00120 #endif